Skip to content
Toolew.com

JSON Sort Keys

Sort JSON object keys alphabetically or in natural order, recursively or at the top level, without changing values.

Runs in your browser. Your data is not uploaded.
Loading tool…

This guide is not yet available in your language and is shown in English.

Tool guide

What this tool does

JSON Sort Keys reorders the properties of every object in a JSON document, A to Z or Z to A, with optional natural number ordering and case-insensitive comparison. It can also sort arrays of plain values or arrays of objects by a chosen property, and keeps every value exactly as written.

Two JSON files can contain identical data and still look completely different because their keys are in a different order. That makes diffs noisy, code reviews slow and merge conflicts more likely, especially for translation files, package manifests and generated configuration where tools add keys wherever they like.

This tool sorts object keys consistently so equal data produces equal text. Object key order has no meaning in JSON according to RFC 8259, so sorting keys does not change what the document represents. Arrays are ordered lists, so they are left alone unless you explicitly ask to sort them. Natural ordering uses the Unicode collation built into your browser, putting “item2” before “item10” as a person would expect. The parser is lossless, so long integers and exact decimal formatting are preserved, and all processing is local.

How to use JSON Sort Keys

  1. Paste JSON into the JSON input box, open a file, or click Sample.
  2. Choose the Order: A → Z or Z → A.
  3. Decide whether to use natural number order, ignore case, and sort nested objects or only the top level.
  4. Optionally sort arrays of plain values, or type a property name in “Sort arrays of objects by property”, such as id.
  5. Pick an Output format: 2 spaces, 4 spaces, tab or minified.
  6. Copy or download the sorted JSON, or sort several files at once and download them as a ZIP.

Tips for better results

  • Sort translation files (en.json, fr.json) the same way so missing keys line up when you compare them side by side.
  • Without natural order, keys are compared by Unicode code unit, so uppercase letters come before lowercase ones; enable “Ignore upper/lower case” for a dictionary-style order.
  • Sorting by a property such as id places objects without that property at the end, in their original order.
  • Run the sorted output through JSON Diff to compare two documents without key-order noise.

Common use cases

  • Normalising package.json dependencies or i18n message files before committing.
  • Producing deterministic output for snapshot tests and checksums.
  • Making exported settings from two environments easy to compare.
  • Ordering a list of records by ID or name for a quick manual review.

Common mistakes to avoid

  • Sorting arrays whose order matters, such as steps, coordinates or priority lists. Leave “Also sort arrays of plain values” off for those.
  • Assuming every consumer ignores key order; a few tools that read JSON as text, or display fields in file order, may be affected.
  • Expecting comments to be sorted with their keys; enable relaxed parsing to accept comments, but they are removed from the output.

Frequently asked questions

Does sorting keys change the meaning of my JSON?

No. JSON objects are unordered collections of name/value pairs, so a parser treats sorted and unsorted versions as the same data. Arrays are ordered and are only sorted if you choose that option.

What is natural order?

Natural order compares runs of digits as numbers, so “v2” comes before “v10”. Plain alphabetical order compares characters one at a time and would put “v10” first.

Can I sort only the top-level keys?

Yes. Turn off “Sort nested objects too” and only the outermost object is reordered; nested objects keep their original key order.

Is this the same as canonical JSON?

It is close. Canonical schemes such as RFC 8785 also define exact number and string formatting. Sorting keys with minified output gives a stable form that is enough for most diffing and caching needs.

Feedback & suggestions

Help us improve JSON Sort Keys. We read every message.

Rating (optional)
Necessary
Required for security, language and theme preferences. Always on.