← All text tools

JSON Key Sorter

Sort the keys of a JSON object alphabetically at every nesting level for stable diffs and tidy config files, ascending or descending.

  • Free
  • No sign-up
  • Works on any device

About JSON Key Sorter

Sorting object keys makes two versions of a file diff cleanly and keeps package manifests and settings files in a predictable order. This sorter walks the whole document and orders the keys of every nested object, ascending or descending, with either case-insensitive comparison or strict character order. Arrays keep their order by default, but you can name a key such as id to order arrays of objects by that value. Number text and string escapes are copied unchanged, so large numbers are not rounded and nothing else about the data changes.

How to use JSON Key Sorter

  1. Paste the JSON into the box.
  2. Pick ascending or descending order, how to compare keys and, if you like, a key to sort arrays of objects by.
  3. Copy the sorted JSON or download it as a file.

Why use this tool?

Also known as

Frequently asked questions

Does sorting the keys change what the JSON means?

No. A JSON object is an unordered set of pairs, so any order has the same meaning. Only the text changes, which is why sorting helps with diffs.

Are arrays sorted too?

Not unless you enter a key name. Then arrays whose items are objects with that key are ordered by its value, and items without the key stay at the end in their original order.

What is the difference between the two comparison modes?

Ignoring case puts alpha before Beta. Strict character order follows code points, so every capital letter sorts before every lower case letter and Beta comes first.

Is JSON Key Sorter free?

Yes. JSON Key Sorter on Toolipedia is free to use, with no sign-up and no watermark.

Is it safe to use?

Yes. Everything is worked out in your browser, and nothing you enter is sent to our server.

Does it work on my phone?

Yes. It works in any modern browser on Android and iPhone, as well as on tablets and computers. There's nothing to install.

Do I need an account?

No. Just open the page and use the tool. There's no sign-up and no email needed.

Can I put JSON Key Sorter on my own website?

Yes. Use the Embed on your site button under the tool to copy a short piece of code and paste it into your page. It is free, needs no account, and the tool keeps working inside your page.

Related tools