Skip to main content

JFormat

A command-line tool for formatting and prettifying JSON files with customizable sorting options.

Quick Start

# Install the package
pip install jformat

# Format a JSON file
echo '{"b":1,"a":2}' > input.json
jformat input.json

Features

  • Pretty print JSON with proper indentation
  • Optional sorting of JSON keys
  • Simple command-line interface
  • Support for large JSON files
  • Preserves JSON data types

Installation

You can install JFormat using pip:

pip install jformat

For development installation:

git clone https://github.com/hwang2006/jformat.git
cd jformat
pip install -e .

Usage

Basic usage:

# Format with default settings (sorted keys)
jformat input.json

# Format without sorting keys
jformat --no-sort input.json

Options

  • --sort / --no-sort: Enable or disable sorting of JSON keys (default: --sort)
  • FILE_PATH: Path to the JSON file to format

Examples

  1. Format a JSON file with sorted keys:
jformat examples/input.json

Input:

{"b": 1,"a": 2,"c": {"z": 3,"y": 4}}

Output:

{
    "a": 2,
    "b": 1,
    "c": {
        "y": 4,
        "z": 3
    }
}
  1. Format without sorting keys (preserves original order):
jformat --no-sort examples/input.json

Development

Setup Development Environment

# Clone the repository
git clone https://github.com/hwang2006/jformat.git
cd jformat

# Create and activate virtual environment (optional)
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install only the core/basic requirements, when you just want to work with the package functionality
pip install -e .

# Install development dependencies, when you plan to develop, test, or contribute to the package
pip install -e ".[dev]"

Running Tests

pytest tests/

Project Structure

jformat/
├── setup.py           # Package configuration and metadata
├── README.md         # Project documentation
├── LICENSE           # MIT License details
├── MANIFEST.in       # Package inclusion rules
├── CHANGELOG.md      # Version history and changes
├── requirements.txt  # Core package dependencies
├── requirements-dev.txt  # Development dependencies
├── examples/         # Example JSON files for testing
│   ├── input.json    # Basic JSON example
│   └── example.json  # Complex JSON example
├── tests/            # Test suite directory
│   ├── __init__.py   # Makes tests a package
│   └── test_formatter.py  # Unit tests for formatter
└── jformat/          # Main package source
    ├── __init__.py   # Package initialization
    └── cli.py        # Command line interface implementation

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Soonwook Hwang - hwang@kisti.re.kr

Acknowledgments

  • Inspired by Python's built-in json.tool
  • Built with Click

Metadata

Release files for jformat 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jformat 0.0.4
File Size Uploaded Provenance
jformat-0.0.4.tar.gz 7.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for jformat 0.0.4
File Interpreter ABI Platform
jformat-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 14.5 kB

Release files / jformat-0.0.4.tar.gz

Download URL jformat-0.0.4.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
48403c07e655b2f50cdd2b5a7362172bd234c39c345d50c8b18c4dcd153df0fd
BLAKE2b-256 checksum
How to use checksums
d1268068bc336dec53d98e806e0a6da143dff5eadda483e3beb96d52340e25e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.11

Release files / jformat-0.0.4-py3-none-any.whl

Download URL jformat-0.0.4-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f67c2c48a595f8001c1fd5ca5bfbc16855d7841bffaf3a031d9ef84be5ed20b4
BLAKE2b-256 checksum
How to use checksums
69190f190bd48825d294a16f4bdb83d042d2488977e5bd0a38365fffee86f431
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.11

Security for jformat 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page