inyourbrowser.com

Sort JSON Keys

Normalise JSON by sorting all keys alphabetically at every nesting level. Makes diffs cleaner and output predictable.

Input JSON
Output

FORMAT

Tips

Paste JSON in the left pane. Output updates instantly.

Runs entirely in your browser

How it works

After JSON.parse turns your input into an in-memory tree, the tool walks every object and rebuilds it with keys in alphabetical order, recursing into nested objects and through array elements. JSON.stringify(sortedValue, null, 2) then emits the normalised tree with two-space indentation. The stable key order makes diffs between two JSON files line up cleanly so real changes stand out.

Processing runs in your browser

All processing happens inside your browser tab. Our servers are not involved at any point.

Related operations

For converting between data formats, try CSV to JSON or the YAML formatter. To decode tokens, use the JWT decoder. For escaping URL data, try URL encode.

Frequently asked questions

Why sort JSON keys?
Sorted keys make it easier to diff two JSON files and to find specific fields quickly.
Does it sort nested objects too?
Yes. Keys are sorted recursively through every level of the object.
Does the order of array items change?
No, only object keys are sorted. Array order is preserved.

Related tools

CSV ↔ JSON
Convert CSV to JSON and JSON back to CSV. Handles quoted fields and downloads.
YAML formatter
Format, validate, and convert YAML. Compatible with Kubernetes, CI configs, and OpenAPI files.
XML formatter
Pretty-print, minify, and validate XML. Uses the browser's native DOMParser.
Regex tester
Test regular expressions with live match highlighting, replace, and split modes.
SQL formatter
Beautify and format SQL queries. Supports MySQL, PostgreSQL, T-SQL and standard SQL.