NV ToolkitFormat · Validate · Convert

JSON Tools

JSON Sorter — Sort Keys A→Z

Recursively sort every object's keys A→Z — arrays keep their order — for stable diffs, clean reviews, and canonical configs.

In short

Sort JSON keys alphabetically online, recursively through every nested object, while preserving array order. Format, validate, and download the sorted result.

By NaveenKumar T · Updated

Learn: What is JSON? A Practical Introduction

  • Recursive A→Z key sorting
  • Array order preserved
  • Choose output indentation

Runs entirely in your browser — nothing you paste or open here is uploaded, logged, or stored.How we handle data →

Example

JSON Sorter: input and output

A user profile whose keys were added in the order they were coded, not alphabetically — a common shape for hand-written fixtures and config.

Input · json
{
  "zipcode": "560001",
  "name": "Priya Nair",
  "active": true,
  "email": "priya@example.com",
  "id": "usr_2291",
  "roles": ["admin", "billing"],
  "city": "Bengaluru"
}
Output · json
{
  "zipcode": "560001",
  "name": "Priya Nair",
  "active": true,
  "email": "priya@example.com",
  "id": "usr_2291",
  "roles": [
    "admin",
    "billing"
  ],
  "city": "Bengaluru"
}

Formatting alone preserves key order exactly as written — zipcode still comes first. Click Sort Keys in the toolbar to alphabetize every object recursively (active, city, email, id, name, roles, zipcode).

Learn more

Canonical JSON through key sorting

Most serializers emit keys in insertion order, which means the same data can take many textual forms. That breaks diffs, cache keys, and signatures. Sorting keys recursively produces a canonical form: one data shape, one byte sequence (at a given indentation). Teams that commit JSON config to git adopt sorted keys early — every diff afterward shows only real changes.

The sorter validates as it parses, so malformed input gets an exact error position instead of a silent failure, and the output is re-serialized at your chosen indentation — 2, 3, 4 spaces or tabs. The JSON pretty printer offers the same recursive sort as an option next to its indentation control; JSON Compare is where sorted output pays off.

What gets sorted (and what never does)

Objects: sorted A→Z by key, case-sensitively, at every depth. Arrays: untouched — ["b","a"] stays ["b","a"] because order is meaningful data. Values inside arrays are still processed, so objects nested in arrays get their keys sorted too. The result parses to a value deep-equal to your original.

Help

Frequently asked questions

Everything you need to know about the JSON Sorter.

01How does the JSON sorter work?

Click Sort Keys and every object in your document — at every nesting level — is rewritten with its properties in alphabetical order. Arrays are never reordered, because in JSON array order is data; only object key order (which carries no meaning) is normalized.

02Does sorting keys change what my JSON means?

No. The JSON specification says object members are unordered, so any compliant parser produces the same result regardless of key order. Sorting only changes how the document reads and diffs — not what it contains.

03Why sort JSON keys at all?

Stable ordering makes diffs meaningful: two configs serialized by different tools stop producing noise-only changes. It also makes large objects scannable (alphabetical lookup) and is the standard first step before comparing documents or committing config to git.

04Can I sort and minify together?

Yes — sort first, then click Minify. The sorted order survives minification, giving you a canonical single-line form that's ideal for hashing or caching keys.

Keep working

Related tools

Learn the format

Related guides

All guides →