π§Ύ JSON Key Sorter β Stable Object Keys
Paste a JSON document to rewrite object keys in alphabetical order. Arrays keep their order. Invalid JSON is reported instead of guessed.
How it works
- Paste a JSON object or array.
- Press Sort keys. Objects are rebuilt with keys sorted by UTF-16 code unit. Arrays stay in place.
- Copy the two-space pretty print. The original text is not changed.
Examples
- {"b":1,"a":2} becomes an object with a then b.
- Nested objects are sorted at every level.
- [{"z":1,"a":2}] sorts keys inside the object and keeps the array.
Frequently asked questions
Does sorting change values?
No. Only object key order changes. Numbers, strings and array order stay the same. Duplicate keys follow the browser JSON parser, which keeps the last value.
Is key order meaningful in JSON?
Parsers may ignore object key order. Sorting is still useful for diffs and reviews.
Is the document uploaded?
No. Parsing and sorting run in the page.
Related tools
More JSON tools βJSON Formatter & Validator
Format, validate and minify JSON instantly. Precise error location with line and column, key sorting, 2/4-space or tab indent, and file download. Free.
JSON Minifier
Compact valid JSON by removing insignificant whitespace after a real parse.
JSON String Escape
Escape text for JSON or unescape a JSON string literal in the browser.
Background Remover
Remove the background from a photo and save a transparent PNG β free, private, no sign-up.