JSON Key SorterONLINE

Sort object properties alphabetically at every level while retaining array order.

1 MiB per input · Ctrl / ⌘ + Enter to run

Only object property order changes. Arrays stay in their original order, and the spelling of numeric values is preserved.

Result
Ready. Paste input, then run the tool.
Your JSON stays in your browser. Core processing happens locally.
THE PRACTICAL GUIDE

Sort JSON object keys for a more consistent review

The key sorter alphabetizes members of every JSON object, including nested objects. It gives collaborators a consistent property order for review.

When should you use it?

  • Normalize fixtures before a text comparison.
  • Make a large object easier to scan alphabetically.
  • Reduce noisy ordering differences in generated data.
WORKED EXAMPLE

Example: alphabetize nested properties

Object members change order at both levels; numbers and array positions do not.

JSON input
{"z":1,"a":{"y":2,"b":3}}
Sorted result
{"a":{"b":3,"y":2},"z":1}

Sort names without reordering the records

Object member order can create noisy text diffs even when the values are unchanged. Recursive key sorting puts names in a consistent order at each object level. Arrays keep their existing order because their positions can carry meaning. The source number tokens are preserved rather than parsed into ordinary JavaScript numbers and written back.

Stable layout is different from canonical serialization

Sorting is useful before reviewing two configuration files, but it does not define a cryptographic canonicalization scheme. Such schemes can also specify number spelling, Unicode handling, and other serialization rules. Use the exact canonicalization required by a signing protocol when generating a signature. Resolve duplicate property names separately, because sorting cannot remove the ambiguity they create for different consumers.

IN PRACTICE

How do I alphabetize JSON object keys without sorting arrays?

Run the key sorter on a valid document. It sorts members at every object level while leaving array positions in place. This is useful when generated objects arrive in different property orders and you want a stable text review.

Nested JSON before and after sorting

text
Before: {"z":1,"a":{"y":2,"b":3}}
After:  {"a":{"b":3,"y":2},"z":1}

The nested object is sorted too. Values and array item order are not alphabetized.

No. This tool changes member order for readability but does not implement a canonicalization standard for signing or hashing. Use the exact format required by your protocol.

BEFORE YOU USE THE RESULT

What should you check before using the result?

Object order may matter to a consumer that treats JSON as text, even though the data model does not assign it meaning. This tool does not sort arrays or deduplicate keys.

Understand JSON syntax

Technical reference: JSON syntax and interoperability · RFC 8259

THE JSON FIELD GUIDE
All guides