Sort JSON Object Keys in Your Browser
Sort strict JSON keys ascending or descending, recursively or at the root, while preserving arrays and original numeric tokens locally.
Tool workspace
JSON Sort Keys
Enable JavaScript to sort JSON locally in your browser.
Keys use UTF-16 text order: "10" precedes "2" ascending. Ignore case folds only A–Z; É and é remain distinct. Root only leaves objects inside a root array unsorted. Arrays always keep their element positions. Whitespace and string escapes may be normalized.
File: 4,000,000 bytes; input: 1,000,000 UTF-16 units; depth: 200 containers; nodes: 100,000; output: 2,000,000 UTF-16 units.
Sorting options
Work budgets: 1,000,000 parse units, 1,000,000 serialization units, 1,000,000 key-order units. Long prefixes or indentation may reach a budget before size limits. These maxima cannot all be guaranteed simultaneously.
Processing stays in your browser. No uploads, remote URLs or saved documents. This is not cryptographic canonicalization or JCS.
{"z":{"2":"dos","10":"diez"},"a":[{"b":2,"a":1}]}Ready to sort.
Diagnostics are incomplete: the inspection stopped or the diagnostic budget was reached.
Select and copy the complete text, or press Copy again with a fresh browser user activation.
Sort object keys explicitly
Paste strict JSON or open one UTF-8 .json file. Select Sort keys to produce a separate result. Defaults are ascending, case sensitive, recursive and two spaces with LF. Four spaces, a tab and minified output are also available. Loading an example or changing options does not start processing.
The shared example is:
{"z":{"2":"dos","10":"diez"},"a":[{"b":2,"a":1}]}
With the defaults:
{
"a": [
{
"a": 1,
"b": 2
}
],
"z": {
"10": "diez",
"2": "dos"
}
}
Text order, case and scope
Decoded keys are compared ordinally by UTF-16 units. Numeric-looking keys are text: "10" precedes "2" ascending. Case sensitive ascending order is A,B,a,b; Ignore case A–Z gives A,a,B,b, breaking ties by the original key. Descending reverses the whole order, including ties. Accents are not folded: É and é remain distinct, and Unicode is not normalized.
Recursive mode sorts every object, including objects inside arrays. Root object only leaves descendant object members in their source order; if the root is an array, it sorts no objects. Arrays always keep their length and element positions. Primitive roots, empty objects and arrays are valid; with no eligible objects, formatting still applies and an informational notice appears.
Preserve values and reject ambiguous input
Strings, decoded keys, booleans, null and structures retain their values. Original numeric tokens 9007199254740993, 0.10000000000000001, -0 and 1E+02 are preserved exactly. A precision warning describes the approximate internal parser value, not rounding in the output. Numbers outside the parser range, such as 1e400, fail explicitly.
{"a":1,"\u0061":2} fails because the decoded key occurs twice; no occurrence is silently overwritten. Comments, JSONC, JSON5 and malformed JSON are rejected. One initial BOM is removed with a notice, while a second BOM is a syntax error. Output is reformatted, with LF, no BOM and no final newline; original whitespace and string escape spelling are not preserved. This is not JCS or cryptographic canonicalization for signatures.
Limits, complete exports and local processing
Files may contain up to 4,000,000 original bytes. Input is limited to 1,000,000 UTF-16 units, depth to 200 containers, source nodes to 100,000 and output to 2,000,000 UTF-16 units. Parsing, serialization and key ordering each have a 1,000,000-unit work budget; long key prefixes or deep indentation can fail before a size ceiling. These maxima are not guaranteed simultaneously. Processing times out after 15 seconds; an output retrieval has a 5-second timeout. At most 100 diagnostics and a 20,000-unit preview are shown.
The truncated preview may be incomplete JSON. Copy all and Download JSON retrieve the full result, including all numeric digits. If clipboard access fails, use the complete manual-copy field or Copy again. Downloads use json-sorted.json, UTF-8 and JSON MIME type.
All processing stays in the browser: no uploads, remote URLs or document storage. You can cancel while keeping input and options. Editing, selecting a file, changing options or clearing invalidates prior results and exports. Clear keeps the chosen options. JavaScript and a Worker-capable browser are required.