JSON Sorter

Sort JSON keys & arrays
online, free & instant

Sort JSON object keys alphabetically or sort arrays by any field. Ascending, descending, nested — all processed in your browser with zero signup.

Open JSON Sorter

Sort JSON in three steps

Paste your JSON Drop any JSON object or array into the input — deeply nested structures are fully supported.
Use Sort By Enter a field name to sort arrays, or leave blank to sort object keys alphabetically. Prefix with - for descending order.
Recursive key sorting Keys are sorted at every depth level, giving you deterministic output ideal for diffs and version control.
Copy the sorted result One-click copy or download the sorted JSON, ready to commit or paste into your config.

No account. No upload. No nonsense.

🔒

No Server

Your JSON never leaves your device. There is no backend to send it to.

Zero Dependencies

Single self-contained HTML file. No frameworks, no CDN calls, nothing to break.

📡

Works Offline

Load once and use forever — even on a plane or without internet access.

Related JSON tools

JSON Formatter Pretty-print JSON with syntax highlighting and a collapsible tree view.
JSON Diff Compare two JSON documents side by side and see exactly what changed.
JSON Minifier Strip all whitespace and compress JSON to the smallest valid form.
JSON Beautifier Format messy JSON into beautifully indented, readable output.

Common questions answered

How do I sort JSON keys alphabetically online?

Paste your JSON into the Format tab and use the Sort By feature. Keys are sorted alphabetically at every level of nesting, giving you a consistent, deterministic key order.

Can I sort JSON arrays by a specific field?

Yes. Enter the field name in the Sort By input to sort an array of objects by that property. Prefix the field name with - (minus) to sort in descending order.

Does sorting JSON change its meaning?

For objects, the JSON spec does not define key order, so sorting keys does not change the semantic meaning. For arrays, order is significant — sort only when you intentionally want to reorder elements.

Is the JSON sort stable?

Yes, the sort is stable. Elements that compare as equal retain their original relative order, which is important for predictable results.

Can I sort nested JSON objects recursively?

Yes. The Sort By feature sorts keys at every depth level in the object tree, so deeply nested structures get consistent key ordering throughout.

What is JSON key sorting?

JSON key sorting reorders object keys alphabetically at every nesting level while preserving all values and array order. This produces deterministic output: the same data always renders identically regardless of original key order. Sorted JSON is essential for meaningful diffs in version control — without it, reordering a key produces a noisy diff that obscures actual changes.

Sorting improves team consistency. When multiple developers edit the same configuration file, each may add keys in different positions. Sorting before committing normalizes the output so git diffs show only actual content changes. This tool sorts keys recursively through all nested objects while leaving array element order untouched, since arrays are ordered by definition.

Sort object keys alphabetically
Input
{
  "zebra": true,
  "apple": 1,
  "mango": {
    "z": 3,
    "a": 1
  }
}
Output
{
  "apple": 1,
  "mango": {
    "a": 1,
    "z": 3
  },
  "zebra": true
}

Get the most out of this tool

Ready to sort your JSON?

Free forever. No signup. Instant results.

Sort JSON now

JSON key sorting and why it matters

Sorting JSON object keys alphabetically is a simple operation with outsized benefits for developer workflows. The JSON specification explicitly states that object key ordering is not semantically significant — two JSON objects with the same keys and values are equivalent regardless of key order. This means sorting keys is always safe and never changes the meaning of the data, while producing several practical benefits for maintainability and tooling.

Version control diff quality is the primary benefit of consistent key ordering. When a developer adds a new field to a JSON configuration file, the diff shows exactly one added line — the new field. Without sorted keys, each developer might write fields in different orders, causing subsequent commits to produce large, noisy diffs showing many "changed" lines that only reflect reordering, not actual content changes. Teams that enforce alphabetical key ordering as a convention see dramatically cleaner Git histories.

Canonical JSON — a standard form of JSON where object keys are always sorted alphabetically and whitespace is minimized — is used in cryptographic contexts. When computing a hash or digital signature over a JSON document, both parties must produce identical byte sequences. If one party serializes {"b": 1, "a": 2} and the other serializes {"a": 2, "b": 1}, they get different hashes despite identical data. Canonical JSON ensures all parties produce the same serialization.

API schema documentation benefits from sorted keys because developers reading examples and comparing schemas can find fields more quickly when they are in alphabetical order. Long JSON examples with many fields are significantly more navigable when sorted — finding whether a field exists is an O(log n) mental binary search rather than a linear scan. Many API documentation generators sort keys for this reason.

Recursive key sorting applies alphabetical ordering at every nesting level, not just the top level. A JSON document with five levels of nesting has keys at each level sorted independently. This is what the "Sort Keys" option in this tool does — every object at every depth gets its keys sorted. The result is a fully canonical form that is stable across any re-serialization of the same data.

Programmatic key sorting is straightforward in every language. In JavaScript: JSON.parse(JSON.stringify(obj, Object.keys(obj).sort())). In Python: json.dumps(obj, sort_keys=True). In Go: the standard library's JSON encoder sorts keys alphabetically by default. Despite this simplicity, an online tool is useful when you have a JSON document and need to sort it quickly without writing any code.

When developers use this tool

Normalizing configuration files Sort JSON configuration files (package.json, tsconfig.json, ESLint configs) before committing. Sorted keys make it easier to see which fields are configured and produce clean diffs when settings are added or removed.
Generating canonical JSON for signing When computing HMAC signatures or checksums over JSON payloads, sort keys first to produce canonical JSON. Both the signer and verifier must agree on the same serialization for the signature to match.
Comparing JSON schemas When comparing two JSON Schema definitions, sort both schemas' keys first. This eliminates spurious differences from key order and lets you focus the comparison on actual structural and constraint differences.
API documentation examples Sort all JSON examples in API documentation so developers reading the docs can find fields quickly. Consistent alphabetical ordering across all examples creates a professional, maintainable documentation experience.

Additional frequently asked questions

Does sorting JSON keys change the data in any way?

No. JSON object key ordering is explicitly not significant per RFC 8259. All compliant parsers produce identical data structures regardless of key order. Sorting keys is a purely cosmetic operation — it changes the serialized representation but never the parsed values or their relationships.

Does the sorter sort keys at all nesting levels?

Yes. The recursive sort option sorts keys alphabetically at every level of the JSON hierarchy — the root object, nested objects, and objects inside arrays all get their keys sorted. This produces a fully canonical form where the entire document is deterministically ordered regardless of how it was originally serialized.

Is there a way to enforce sorted JSON keys automatically in a codebase?

Yes. Prettier (version 2.x+) sorts JSON object keys when formatting .json files. ESLint with the json-sort-keys rule can enforce alphabetical key ordering. For Python, isort-json and similar tools exist. For Git pre-commit hooks, you can run a JSON formatter with key sorting enabled to normalize all JSON files before committing.

What sorting algorithm is used for JSON keys?

Keys are sorted using the Unicode code point order, which is the same as lexicographic byte order for ASCII characters. This means uppercase letters (A-Z, code points 65-90) sort before lowercase letters (a-z, code points 97-122). If you need case-insensitive sorting (where "Age" and "age" are adjacent), use a custom comparator in application code rather than this tool's default sort.