--- id: compact-json version: "1.8.2" license: MIT license_treatment: permissive maintenance: aging --- # compact-json — A JSON formatter that produces compact but human-readable License: permissive · Maintenance: aging · Downloads: 1.1M/mo ## What it is and what it does compact-json is a JSON formatter that balances readability with compactness by applying three formatting strategies: fitting simple objects and arrays onto a single line when they are short and not deeply nested, arranging complex lists across multiple lines with several items per line, or expanding each property or array item onto its own indented line. It exposes a Formatter class with configurable properties like max_inline_length, max_inline_complexity, and indent_spaces, allowing you to tune the output to your needs. It also provides a command-line utility for formatting JSON files directly from the shell. The package is now deprecated and its maintainers explicitly recommend migrating to fractured-json, which tracks the upstream FracturedJson .NET project. Despite the deprecation notice, compact-json remains functional and receives occasional maintenance; it supports Python 3.9 through 3.14 and has no known security vulnerabilities. The three runtime dependencies are lightweight and widely available. Use it for: - Format API responses or configuration files to a compact but readable form for logging or debugging without the verbosity of standard pretty-printing. - Reduce JSON file size while keeping the output human-readable for version control or data interchange. - Configure formatting rules (line length, nesting depth, indentation) to match your project's style guide or readability preferences. - Use the command-line tool in shell pipelines to format JSON from stdin or batch-process multiple JSON files with consistent settings. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Formats JSON into compact, human-readable output by fitting objects and arrays onto single lines when they fit within configured length and complexity limits, falling back to multi-line formatting for larger structures. Yes, if you need compact JSON formatting and can accept the aging maintenance status. The package is stable, has no known vulnerabilities, and works with current Python versions. However, the explicit deprecation notice and recommendation to migrate to fractured-json suggest this is a good time to evaluate whether that alternative better suits your long-term needs. Install only if you are comfortable with a package that receives infrequent updates. ## Install pip install compact-json uv add compact-json poetry add compact-json ## Installing compact-json Before you install: Low install friction with three lightweight runtime dependencies (wcwidth, setuptools, importlib-resources). Maintenance status is aging—last release was 231 days ago—but the package is not archived and the repository remains active with 41 stars. License in practice: MIT license permits commercial and private use with minimal restrictions; you may use, modify, and distribute the package freely provided you retain the license notice. Quickstart: import json from compact_json import Formatter formatter = Formatter() formatter.indent_spaces = 2 formatter.max_inline_complexity = 10 with open("input.json", "r") as f: obj = json.load(f) json_string = formatter.serialize(obj) print(json_string) Requires Python 3.9 or later (supports up to 3.14); package is deprecated and maintainers recommend migrating to fractured-json. Verify before relying: - Whether the aging maintenance status (231 days since last release) affects stability or compatibility with recent Python patch versions. - Performance characteristics when formatting very large JSON files or deeply nested structures. - Real-world adoption and whether the deprecation notice has driven users away to fractured-json. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 1.1M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags json formatter compact, human readable json output, configurable json formatting, json line length control, pretty print json compact, json-formatting, cli-tool [View on SkillFed](https://skillfed.io/packages/compact-json) · [View on PyPI](https://pypi.org/project/compact-json/)