JSON Key Sorter (Stafla Key Order for Cleaner Diffs)

Automatically standardize JSON key order to make yfirferðs and samanburðurs easier.

Choose all levels or top level only. Array order stays intact.

Cleaner diffs with fixed key order
Array order is preserved
Indentation formatting in the same run
Processing runs entirely in this page (nothing is uploaded).

Verkfæri

Sort and format JSON in one step, then copy or download the niðurstaða.

Shortcut: Ctrl / Cmd + Enter to run

Sample (Before / After)

Inntak

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

All-level sort (2 spaces)

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

Top-level only sort

Top-level keys are reordered to a, arr, b, while key order inside "a" stays as entered.

How to use

  1. Paste JSON into the inntak area.
  2. Choose scope (all levels/top level) and indentation.
  3. Click Sort and Format, then copy the úttak.

What You Can Do

  • Sort object keys ascending or descending
  • Choose all levels or top-level only
  • Keep array element order unchanged
  • Copy, download, and swap inntak/úttak

Specifications (Arrays, Nesting, Numeric Keys)

  • Object keys are sorted lexicographically, with selectafla scope (all levels or top level only).
  • Array element order is preserved.
  • Indent options: 2 spaces, 4 spaces, tab, or minified one-line úttak.
  • If inntak is not valid JSON, an error is shown and úttak is not updated.
  • Integer-like keys may appear in numeric order depending on JavaScript property enumeration rules.

Algengar spurningar

Can nested objects be sorted too?

Yes. You can choose all levels or top level only.

What happens to arrays?

Array element order is preserved. Objects inside arrays are sorted depending on your selected scope.

Can I keep original indentation?

Inntak formatting is not preserved. Úttak is reformatted using your selected indentation style.

Does it support JSON5 comments or trailing commas?

No. This verkfæri targets standard JSON only.

Where is data processed?

Everything runs locally in your browser. Your inntak is not sent to a server.