Zero Signup ToolsFree browser tools

Developer Tools

JSON Sort Keys

Sort JSON object keys alphabetically in your browser. Ascending or descending, deep or top-level, case-sensitive or natural numeric order.

0 chars

Sort options

All settings update the result live. Array order is always preserved; only object keys are reordered.

Direction
Scope
Case
Numeric
Output format

How keys are compared

  • A to Z is the default direction. Switch to Z to A to reverse the order at every level.
  • Deep sorts keys at every nested object. Top level only touches the root object and leaves child objects in their original order.
  • Case sensitive compares uppercase before lowercase the way pure string sort does (Apple before banana). Case insensitive folds both before comparing (apple ties with Apple).
  • Codepoint is the plain JavaScript string comparison: file10 sorts before file2.
    Natural uses Intl.Collator with numeric: true so file2 sorts before file10.

Why sort JSON keys

  • Deterministic output makes diffs in pull requests focus on real changes, not key insertion order.
  • Stable input for hashing or signing. The same data always produces the same bytes.
  • Snapshot tests stay readable when keys do not shuffle between runs.
  • Easier to scan a long config file by alphabetical key.
  • Side-by-side comparison of two API responses lines up matching fields automatically.

Parsing and sorting run entirely in your browser using the native JSON parser. Nothing is uploaded.

How to use

  1. Paste any valid JSON document into the input on the left. Click Load sample if you want to see a worked example.
  2. Pick a direction. A to Z is the default; Z to A reverses every level.
  3. Pick a scope. Deep sorts keys at every nested object; Top level only leaves child objects in their original order.
  4. Pick a case and numeric mode. Case insensitive ties Apple with apple. Natural numeric order puts file2 before file10.
  5. Pick an output format (2 spaces, 4 spaces, tab, or minified) and click Copy sorted to grab the result.

About this tool

JSON Sort Keys reorders the keys of any JSON object alphabetically so the output is stable, diff-friendly, and easy to scan. Paste any valid JSON document and the result panel updates as you type. Choose the direction (A to Z or Z to A), the scope (deep, which sorts keys at every nested object, or top level only, which leaves child objects in their original order), the case mode (sensitive treats uppercase A before lowercase a per the standard string comparison, insensitive folds both before comparing), and the numeric mode (codepoint is the plain JavaScript string order where file10 sorts before file2, natural uses Intl.Collator with numeric: true so file2 sorts before file10 the way most file managers do). Output can be emitted as pretty-printed JSON with 2 spaces, 4 spaces, or tab indentation, or minified onto a single line. Array order is always preserved; only object keys are reordered. Sorting is stable and idempotent, so running the same input twice produces the same output. Common uses include normalizing config files before committing, generating diff-friendly snapshots for code review and snapshot tests, producing stable input for cryptographic hashing or signing, comparing two API responses that have the same fields in a different order, and tidying long objects so a future reader can find keys alphabetically. All parsing and sorting happen locally in the browser using the native JSON parser, so the JSON you paste here never leaves your device.

Free to use. Works in your browser. No signup, no login.

Related tools

You may also like

All tools
All toolsDeveloper Tools