Skip to main content
Convert2JSON Tools

JSON Sorter

Alphabetise the keys of every object in a document so two versions line up and diff without noise.

Your data stays on your device

Input — JSON

characters
0
lines
0
size
0 B

Output — Sorted JSON

characters
0
lines
0
size
0 B

Options

About this tool

JSON objects have no guaranteed key order, so two payloads that are logically identical can produce a messy line-by-line diff purely because their keys are arranged differently. Sorting both sides removes that noise.

This tool rewrites every object in the document with its keys in alphabetical order, recursively, while leaving array element order exactly as it is — because array order is meaningful in JSON and reordering it would change the data.

How to use this tool

  1. Paste the JSON whose keys you want to sort, or upload a file.
  2. Pick an indentation style for the output.
  3. Press Sort keys to alphabetise every object recursively.
  4. Copy or download the sorted document, and repeat for the other side you want to compare.

Key features

  • Recursive alphabetical sorting of all object keys
  • Array element order preserved intact
  • Choice of 2 spaces, 4 spaces or tab indentation
  • Ideal companion to the JSON Compare tool
  • No data leaves the browser

Example

Keys are reordered alphabetically

InputJSON

{"name":"Ada","id":42,"active":true}

OutputJSON

{
  "active": true,
  "id": 42,
  "name": "Ada"
}

Good to know

  • Array order is never changed, since that would alter the data. Only object keys are sorted.
  • Sorting is by Unicode code point, so capital letters sort before lowercase ones.

Frequently asked questions

Why would I sort JSON keys?

Mainly for stable diffs and reproducible output. Sorting both documents makes a text diff reflect real value changes instead of key-order changes.

Does it sort array items too?

No. Arrays keep their order because it carries meaning. Only the keys inside objects are reordered.

Is the operation lossless?

Yes. Only key order changes; every key, value and type is preserved.

Your data stays on your device

Your data is processed locally in your browser and is not uploaded to our server. This page keeps working after you go offline, because there is nothing to send.

Share this toolXLinkedInHacker News