Sort JSON object keys alphabetically with recursive and depth options
JSON keys are technically unordered according to the specification — but in practice, consistent key ordering makes JSON easier to read, compare, and diff. When keys appear in random order across two versions of a config file, a git diff becomes noise instead of signal. Sorting JSON keys alphabetically before committing makes reviews cleaner and reduces merge conflicts. This tool recursively sorts all keys at every level of nesting.
Beyond git diffs, sorted JSON is helpful for canonical serialisation (ensuring two JSON objects with the same content produce the same string for signing or caching), for enforcing style guidelines in config files, and for making large JSON documents navigable without a tree viewer. The tool also formats the output with configurable indentation.
No. The JSON specification (RFC 8259) explicitly states that object keys are unordered. However, most parsers preserve insertion order in practice, and many developers rely on this. Sorted JSON is a matter of style and diffability, not correctness.
No. Arrays are ordered by definition — rearranging array elements would change the data. The sorter sorts object keys only; array elements remain in their original order.
Recursively. Every object at every depth of nesting has its keys sorted. A deeply nested config like {"z": {"y": 1, "a": 2}} becomes {"z": {"a": 2, "y": 1}} — the inner object keys are sorted too.
Sorting JSON by value doesn't have a universal meaning for objects (what does it mean to order keys by their corresponding value types?). For arrays of primitives, value sorting is well-defined. For key-value object sorting, only key-alphabetic sort is universally useful.
JSON Formatter · JSON Minifier · JSON Validator · JSON to CSV · JSON ↔ YAML · JSON Flatten