Options
JSON
Drop the file to open it
Sorted JSON
The sorted JSON appears here as you type.

Paste JSON and every object's keys are sorted alphabetically as you type, at every level of nesting. Choose A to Z or Z to A, case-insensitive, code point, or natural order, sort arrays too if you want, and pin keys like $schema or id to the top. Values are never changed, so long numbers and IDs stay exact. It also sorts JSON Lines files line by line. Everything runs in your browser.

How to sort JSON keys alphabetically

  1. Paste your JSON into the left pane, or open a .json or .jsonl file.
  2. The sorted JSON appears on the right. If the JSON has an error, the exact line and column are shown.
  3. Pick the order and how keys are compared. Natural order puts item2 before item10.
  4. Click Copy or Download .json.

Sort options explained

OptionExample orderWhen to use it
Ignore caseapple, Banana, cherryMost readable for people
Uppercase first (code point)Banana, apple, cherryMatches jq -S, Python's sort_keys=True, and most sorted-JSON tools, so diffs line up
Naturalitem1, item2, item10Keys that contain numbers, like versions or numbered fields
Keep first$schema, name, then the rest A to ZConfig files where a few keys belong at the top
Sort arrays: values[3, 1, 2] becomes [1, 2, 3]Lists of tags, IDs, or names where order doesn't matter
Sort arrays: by a keyObjects ordered by their name or idLists of records you want in a predictable order

Arrays keep their order unless you choose otherwise, because in JSON an array's order usually means something.

Why sort JSON?

  • Cleaner diffs: when two JSON files have the same data in a different order, sorting both makes the real differences stand out in Git or a diff tool.
  • Easier reading: finding a key in a large API response or config file is much faster when keys are in order.
  • Consistent files: translation files, settings, and fixtures stay tidy when everyone's changes end up in the same order.

Sorting JSON with code

With jq, run jq -S . file.json. In Python, use json.dumps(data, sort_keys=True, indent=2). In JavaScript there's no built-in option, so you need a small recursive function, or JSON.stringify with a replacer that rebuilds each object with sorted keys. All three sort by code point, which matches the Uppercase first option here.

Frequently asked questions

Does sorting change my data?

No. Only the order of keys in objects changes, plus array order if you turn that on. Every value stays exactly the same, including long numbers that many tools would round.

Does key order matter in JSON?

Not for meaning. The JSON standard treats objects as unordered, so a sorted file means the same thing as the original. Some tools and people still rely on order for readability, which is why Keep first exists.

Can it sort nested objects?

Yes. By default every object at every depth is sorted, including objects inside arrays. Choose Top level only to sort just the outermost keys.

Can I sort JSON with comments, like tsconfig.json?

Yes, with Allow comments and trailing commas turned on. The comments are removed in the output, because standard JSON can't hold them.

What about duplicate keys?

They're kept and listed under the panes, so you can see them side by side after sorting. Most parsers would keep only the last one.

Is my JSON uploaded anywhere?

No. Sorting happens in your browser and nothing is sent to a server.

Our Full Dev Tool Library

Flipper File