JSON key sorter for consistent, readable diffs

Standardize JSON key order automatically to make reviews and comparisons easier.

Choose every level or the top level only. Array order stays intact.

Clearer diffs with a consistent key order
Array element order stays unchanged
Format indentation in the same pass
Processing happens entirely on this page; nothing is uploaded.

Try the tool

Sort and format JSON in one step, then copy or download the result.

Shortcut: press Ctrl / Cmd + Enter to run

Example: before and after

Input

{"b":1,"a":{"d":4,"c":3},"arr":[{"y":2,"x":1},3]}

Sort every level (2 spaces)

{
  "a": {
    "c": 3,
    "d": 4
  },
  "arr": [
    {
      "x": 1,
      "y": 2
    },
    3
  ],
  "b": 1
}

Sort the top level only

Top-level keys become a, arr, b, while the key order inside "a" stays as entered.

How to use

  1. Paste JSON into the input area.
  2. Choose the scope (every level or top level) and indentation.
  3. Select Sort and format, then copy or download the output.

What you can do

  • Sort object keys in ascending or descending order
  • Choose every level or the top level only
  • Keep array elements in their original order
  • Copy, download, or swap the input and output

Specifications: arrays, nesting, and numeric keys

  • Object keys are sorted lexicographically; you can apply the sort at every level or only at the top level.
  • Array element order is preserved.
  • Indent options: 2 spaces, 4 spaces, a tab, or compact one-line output.
  • If the input is not valid JSON, an error appears and the output remains unchanged.
  • Keys that look like integers may appear in numeric order because of JavaScript property-enumeration rules.

FAQ

Can nested objects be sorted too?

Yes. Choose every level to sort nested objects, or choose top level only to leave nested key order unchanged.

What happens to arrays?

Array element order is preserved. Objects inside arrays are sorted when they fall within your selected scope.

Can I keep original indentation?

The original whitespace is not preserved. Output is reformatted with the indentation style you select.

Does it support JSON5 comments or trailing commas?

No. This tool accepts standard JSON only; JSON5 comments and trailing commas are not supported.

Where is data processed?

Everything runs locally in your browser. Your input is never sent to a server.