Sort JSON object keys alphabetically — recursively, in natural or case-insensitive order, with pinned keys. Numbers and strings stay exactly as written.
Paste a JSON document into the input pane. The tool parses it as strict JSON and prints the same document with every object's keys in sorted order. Pick the direction, indentation and options in the toolbar — the output updates as you type.
Only the
order of keys
, whitespace and line breaks change. String and number literals are copied from your input character by character, so large integers such as
9007199254740993, trailing zeros like
1.2300
and exponents like
1e400
survive intact. A regular
JSON.parse
/
JSON.stringify
round-trip would silently round or rewrite them.
Input:
{"name":"api","id":7,"limits":{"burst":20,"rate":100}}
Output with default options and id pinned first:
{
"id": 7,
"limits": {
"burst": 20,
"rate": 100
},
"name": "api"
}
The default order compares keys by UTF-16 code units, the same way JavaScript compares strings with
<. It does not depend on your browser locale, so the result is identical on every machine:
"1", "10", "2", "A", "a", "b". Z→A reverses the order of all keys that are not pinned.
When enabled, nested objects are sorted too, including objects inside arrays. Turn it off to reorder only the top-level object and leave everything below untouched.
Natural (numeric) sorting compares runs of digits by their value, so
item2
comes before
item10
. Signs, dots and exponents have no numeric meaning — only plain ASCII digits are compared as numbers.
Compares lower-cased keys, so
Name
and
name
sit next to each other.
"A"
and
"a"
remain two different keys; when they tie, the original strings decide, so the output never depends on the input order.
Pinned keys are placed first in every sorted object, in the order you list them. It's a common convention to keep
id,
name
or
type
at the top. Pinned keys that don't exist in an object are ignored.
package.json-style files in one canonical order so code reviews show real changes only.
1
and
1.0
or
"é"
and
"\u00e9"
stay different. Don't use it as the input for cryptographic signatures.
The sorting engine is the open-source
@helpers-work/json-sort
library, which also ships a CLI with a
--check
mode for CI pipelines.
No. Sorting runs entirely in your browser with the open-source @helpers-work/json-sort library. The JSON you paste never leaves your device.
No. Number and string literals are copied exactly as written, so values like 9007199254740993, 1.2300 or 1e400 stay unchanged. Only key order, whitespace and line breaks change.
No. Array order is usually meaningful, so array elements keep their original order. Objects inside arrays are still sorted when recursive sorting is enabled.
With natural sorting, runs of digits are compared by value, so "item2" comes before "item10". Without it, keys are compared character by character and "item10" comes first.
The sorter is strict: duplicate keys, comments and trailing commas are errors. Duplicate keys are rejected because JSON.parse silently keeps only the last value, which can hide real bugs.
Only with care. The output is deterministic for the same input and options, but it is not RFC 8785 canonical JSON: 1 and 1.0 stay different. Use a JCS implementation for cryptographic signatures.