Online JSON Sort Keys Tool

Alphabetize object keys recursively across all nested levels for deterministic JSON output, diffing, and hashing.

Runs locally 0 lines • 0 bytes Ready
Tip: drop a file anywhere on the page
Input
Paste, type or drop a file
Result
Updates as you type
// Output will appear here…
About this tool

How the JSON Sort Keys works

Sort JSON object keys alphabetically (A-Z or Z-A). Deep recursive sorting for deterministic, canonical JSON comparisons and hashing.

How to use the JSON Sort Keys

  1. Paste a JSON object.
  2. Choose A–Z or Z–A order; nested objects are sorted too.
  3. Copy the sorted JSON.

JSON Sort Keys example

Input
{"b":1,"a":{"d":2,"c":3}}
Result
{"a":{"c":3,"d":2},"b":1}

When to use it

  • Producing clean, stable git diffs for JSON files.
  • Creating deterministic JSON before hashing or signing it.
  • Making large config files easier to scan.

Tip: Array order is preserved, because reordering array items would change the data.

Alphabetical Ordering (A-Z / Z-A)

Sort object properties in ascending (A to Z) or descending (Z to A) alphabetical order.

Deep vs. Shallow Sorting

Choose between recursive sorting of all nested objects or sorting top-level keys only.

Deterministic JSON Output

Produces canonical key order ideal for cryptographic hashing, snapshot testing, and version control.

Preserves Array Order

Safely sorts object keys within arrays while maintaining the exact element order of array items.

FAQ

Common questions

Why should I sort JSON keys?

Sorting keys produces deterministic, canonical JSON. This is essential for computing consistent hash values, creating clean git diffs, and comparing API responses.

Does sorting keys change array element order?

No. Array item order is strictly preserved. If array elements are objects, only their internal keys are sorted.

What is the difference between Deep and Shallow sort?

Shallow sorting only alphabetizes the top-level keys. Deep sorting traverses every nested object recursively.

Can I sort keys in descending order?

Yes, select Z → A from the sort direction dropdown to reverse alphabetical ordering.