JSON Key Sorter
Sort JSON object keys recursively by alphabet, case or value type with ascending/descending order and configurable indentation. Free, instant and fully client-side.
Loading tool...
What is JSON Key Sorter?
A JSON Key Sorter recursively rewrites JSON objects with their keys in a consistent order β alphabetical, case-sensitive, or grouped by value type β so repeated runs of the same data always produce byte-identical output for snapshot tests, fixtures and readable diffs.
Key Benefits
- Deterministic output for snapshot tests and golden files
- Diffs that show real changes instead of shuffled keys
- Sorted config and translation files that are easier to scan and review
Common Use Cases
- β’Normalizing API fixtures before committing them to a repository
- β’Preparing stable JSON for snapshot or golden-file testing
- β’Tidying hand-maintained config, i18n and manifest files
How to sort JSON keys
- Paste your JSON: Drop the JSON document, API response or config file into the input box β any valid JSON works, at any nesting depth.
- Pick the sort mode: Choose case-insensitive or case-sensitive alphabetical order, or group keys by value type, then set the direction and indentation.
- Copy the stable output: The sorted JSON updates live β copy it back to your snapshot test, fixture or config for deterministic diffs.
Key Features
- Recursive key sorting for objects nested anywhere, including inside arrays
- Case-insensitive alphabetical mode with case-sensitive tie-breaking
- Value-type ordering: null, boolean, number, string, array, object
- Ascending or descending order plus 2/4-space or tab indentation
- Live re-sorting as you type with exact JSON parse error messages
Frequently Asked Questions
Does sorting change array element order?
No. Arrays are left in their original order; only object keys are rearranged. Objects inside arrays are sorted recursively just like top-level objects.
What order does the "by value type" mode use?
Keys are grouped by their value type in this order: null, boolean, number, string, array, then object. Within the same type, keys are sorted alphabetically (case-insensitive).
How does case-insensitive sorting handle ties?
When two keys differ only by case (like "user" and "User"), the case-sensitive comparison breaks the tie, so uppercase-first ordering is deterministic.
Is my JSON uploaded anywhere?
No. Parsing and sorting happen entirely in your browser with JavaScript; the document never leaves the page.