JSON Key Sorter

Sort JSON object keys alphabetically, by length, or in reverse — with recursive nested object support

Sort Order
Indent
JSON Input
Sorted Output

JSON Key Sorter

Sort JSON object keys alphabetically, by length, or in reverse — with recursive nested object support

Features

  • Recursively sort JSON keys alphabetically (or only top-level if recursion is off)
  • Toggleable recursive mode
  • Pretty-printed output with 2-space indent
  • Stats: total keys, depth
  • Runs entirely in your browser

How to use

  1. Klistra in JSON i inmatningsfältet.
  2. Välj sorteringsordning och alternativ.
  3. Klicka på Sortera nycklar.
  4. Kopiera det sorterade resultatet.

Tips & Best Practices

  • Sorted JSON gives stable diffs — useful for committing JSON config files where the original order is arbitrary.
  • Arrays are left in their original order (JSON arrays are sequences, not sets — order is semantic).
  • For deterministic JSON output across languages, JSON Canonical Form (RFC 8785) goes further than alpha-sorting; use a library for that.
  • For very large JSON, the parse+stringify round-trip is fine but memory-bound — files >100 MB may stress the browser.
  • Mixed-type arrays (objects + primitives) sort the object members internally; the array itself stays in order.

FAQ

Varför sortera JSON-nycklar?

Att sortera nycklar gör JSON lättare att jämföra, granska i pull requests och upprätthålla konsekvens i konfigurationsfiler.

Ändras värdena?

Nej, bara ordningen på nycklarna ändras. Alla värden, arrayer och datatyper förblir oförändrade.