JSON Key Sorter
Put JSON keys in alphabetical order so the file is easier to read and compare. Choose whether to sort keys inside nested objects too.
Paste JSON below or import a .json file. Choose the key order, nested sorting and spacing, then select Validate and sort. Copy or download the result below. Processing stays in your browser; refreshing clears your draft.
0 bytes of 2 MiB maximum. Strict JSON only.
Advanced settings
Settings files exclude JSON, schema text, filenames and results. Import turns schema ordering off.
How to use JSON Key Sorter
Paste strict JSON or import a UTF8 .json file up to2MiB. Choose ascending or descending order and spacing, then Validate and sort. The default sorts decoded key code points and preserves numeric tokens. Keep recursive sorting on for nested objects and objects inside arrays; off sorts only a root object. Copy, download or use the result as input. Clear and Undo work until the next edit. Duplicate keys, comments and trailing commas are rejected.
Open Advanced settings and enable custom rules when needed. Priority keys come first in your listed order, then any written schema properties, then key or value ordering. Descending applies only to the remaining comparator. Ignore letter case uses locale-independent lowercase; natural ordering compares digit runs without rounding. Equal comparisons keep source order. Advanced key comparisons use UTF16 ordering. By-value order is null, false, true, numbers, strings, arrays, objects; arrays and objects tie within their type.
Selected JSON Pointers sort only those exact objects. Include root explicitly for the whole root object. Children need their own paths. Escape a key slash as ~1 and tilde as ~0. A missing path or a non-object is an error. Array item order never changes; whitespace is formatted throughout the document.
Schema layout follows literal written properties, including numeric-looking keys. Inline nested properties and array items are followed when the basic recursive choice allows sorting, or at selected objects. No schema validation, reference resolution or remote fetching is performed. Schema input is limited to256KiB.
The change preview shows one complete common-prefix/suffix block, up to150 lines per side. It is not a minimal edit script; the text download contains the whole block. Batch sorting accepts up to12 independent files,2MiB each and8MiB combined. Successful outputs and a manifest of every failure go into the ZIP. Combined output and ZIP are capped at32MiB. Cancel stops the worker and keeps input and the last completed batch. Single work has8seconds; batch work30seconds.
Portable settings include rules and basic spacing, never JSON, schema text, filenames or results. Import validates before applying and turns schema ordering off. Closing Advanced settings keeps choices and results. Reset keeps your JSON.
Example: put important settings first
For {"item10":10,"name":"Demo","item2":2,"id":7}, enable advanced sorting, list id and name as priorities and turn on natural order. The result begins with id and name, followed by item2 and item10. Values remain unchanged. A schema with written properties name then id instead puts those fields first when no priority list overrides them.
About canonical JSON and limits
RFC8785 JSON Canonicalization Scheme (JCS) is an explicit separate mode. It recursively sorts decoded keys by UTF16 code units, uses ECMAScript primitive serialization, removes whitespace and the trailing newline, keeps array order and does not normalize Unicode. It ignores custom rules, scope and basic indentation while retaining those choices for later.
This tool adds a conservative input restriction: numbers must be finite binary64 values whose serialization preserves the exact decimal value written. It accepts -0 as0 and 1.2300e2 as123, but rejects9007199254740993 and other inputs that would round. This restriction rejects some otherwise valid JCS inputs. Unpaired Unicode surrogates are rejected. The SHA256 button hashes the exact UTF8 output bytes; a hash is not a signature or proof that data is trustworthy. The JCS RFC is informational; no certification is claimed.
Original limits remain2MiB input,100 nesting levels,100000 values,1000 characters per number token and10MiB output. Everything is processed locally without executing JSON, uploading data or automatically saving drafts. Explicit downloads may contain all source data. Keep sensitive files private. Read RFC8785.
Stars and feedback
Loading…
What could we improve in JSON key sorter?
Email us feedback@tooltulip.com
Tool reference #121