Skip to content
XUtilHub

JSON Sorter – Sort JSON Keys Alphabetically

Sort JSON object keys alphabetically (A-Z or Z-A), recursively through nested objects. Makes JSON diffs and reviews easier.

  • Free, no sign-up
  • Runs in your browser, nothing uploaded
Input
Output

About the JSON Sorter

Sort the keys of every object in your JSON alphabetically, ascending or descending. Sorted JSON is easier to read, review and compare.

Key features

  • Sort object keys A→Z or Z→A
  • Sorts recursively through every nested object
  • Natural ordering: key2 comes before key10
  • Array order is preserved (arrays are data, not keys)
  • Choose 2-space, 4-space or tab output
  • Instant, private, no upload

Why sort JSON keys?

JSON objects are unordered by definition, but people still read them in order. When two systems serialize the same data with keys in a different order, comparing them becomes painful. Sorting keys alphabetically gives every document a canonical order, which makes reviews, diffs and lookups much easier.

Example

{ "zip": "N1", "name": "Ada", "address": { "street": "1 Way", "city": "London" } }

sorted A→Z:

{
  "address": {
    "city": "London",
    "street": "1 Way"
  },
  "name": "Ada",
  "zip": "N1"
}

Great uses for a JSON sorter

  • Cleaner Git diffs. Commit config files with sorted keys and only real changes show up in diffs.
  • Comparing API responses. Sort both before comparing them; better still, use JSON Compare, which ignores key order automatically.
  • Translation files. i18n files like en.json are much easier to maintain alphabetically.
  • Code review. Reviewers find fields faster in alphabetical order.
  • Deterministic output. Hashing or signing JSON requires a stable key order.

How sorting works

  1. Every object at every level has its keys sorted using natural, locale-aware ordering.
  2. Arrays keep their original element order, but objects inside arrays are sorted too.
  3. Values are never modified.
Input keysA→Z result
b, a, Ca, b, C
item10, item2, item1item1, item2, item10
_id, id, Id_id, id, Id

Tip: sorting for canonical JSON

For signing or hashing, you usually need sorted keys and no whitespace. Sort here, then run the result through the JSON Minifier.

Sort, then format or validate. To reorder lines of plain text, use Sort Text Lines.

How to use the JSON Sorter

  1. Paste your data into the input box, upload a file, or click Sample to try it out.
  2. Adjust the options above the editor if you need to (indentation, delimiter, and so on).
  3. The result appears instantly in the output panel. Any errors are shown with their line and column.
  4. Click Copy to copy the result, or Download to save it as a file.

Frequently asked questions

Does sorting change the meaning of my JSON?

No. The JSON standard says object key order has no meaning, so sorted JSON represents exactly the same data. Array element order does matter, so arrays are never reordered.

Why is key10 placed after key2?

The sorter uses natural (numeric-aware) ordering, which matches how people expect numbered keys to be listed.

Is the sort case-sensitive?

Sorting uses locale-aware comparison, so 'apple' and 'Apple' sit next to each other instead of all capitals coming first.

Can I sort an array of objects by a field?

Not with this tool. It sorts keys within objects. To reorder array items by a value, use a JSONPath query or sort in code.

Is my JSON uploaded to a server?

No. All JSON tools run entirely in your browser, so your data never leaves your device.

Is there a size limit?

There is no fixed limit. Files of several megabytes work fine; very large files depend on your device's memory.

Do I need an account?

No. Every JSON tool is free and works without signing up.

Last updated:

Related JSON tools