JSON Sorter Online

Sort JSON keys alphabetically in ascending or descending order, recursively through all nested objects.

A JSON key sorter reorders every object's keys alphabetically — A→Z or Z→A — throughout the entire JSON document, at all nesting levels. Sorting JSON keys normalises key order for cleaner Git diffs, stable test fixtures, consistent hashing, and easier manual scanning. Array elements are never reordered — only object keys change.

starstarstarstarstar
4.8· 654 ratings
shieldRuns entirely in your browser
cloud_offNo data stored or uploaded
volunteer_activismFree forever
Order:
1234567891011121314151617181920
1234567891011121314151617181920

What Is a JSON Key Sorter?

A JSON sorter reorders the keys of every object in a JSON document alphabetically — either ascending (A→Z) or descending (Z→A) — while preserving the full structure, values, and nested relationships. Array element order is never changed.

Sorted JSON is easier to scan manually, produces deterministic text diffs in version control, and ensures consistent key ordering across environments — eliminating spurious diff noise caused by arbitrary key insertion order. Use our JSON Compare tool after sorting to do a structural diff, or our JSON Formatter to clean up the indentation.

Per RFC 8259, JSON object key order is not semantically meaningful — sorting only affects the textual representation, never the parsed data. Use our JSON Validator if sorting fails due to invalid JSON.

Common Use Cases

  • check_circleSort JSON keys before committing to version control for clean diffs
  • check_circleNormalise key order in API responses for consistent test assertions
  • check_circleSort config file keys alphabetically for easier manual scanning
  • check_circleStandardise key order across multiple JSON exports for comparison
  • check_circleSort object keys before hashing or signing a JSON payload
  • check_circleAlphabetise JSON schema properties for documentation consistency

How to Sort JSON Keys Online – Step by Step

1

Choose sort direction

Select A→Z for ascending alphabetical order (the most common) or Z→A for descending. The direction applies to all nesting levels.

2

Paste your JSON

Copy JSON from any source — a config file, API response, schema, or code editor — and paste it into the input panel on the left.

3

Click Sort and copy

Press Sort to instantly reorder all object keys. Copy the sorted JSON to use in your codebase, test fixtures, or documentation.

When Should You Sort JSON Keys?

Sorting JSON keys is most valuable when consistent ordering matters — for diffs, hashing, documentation, or team-wide conventions.

history

Before Git Commits

Different serialisers insert keys in different orders. Sorting before committing ensures clean, minimal diffs — no noise from key-order churn between developers.

fact_check

Stable Test Fixtures

Test fixtures that depend on key order are brittle. Sorting normalises the order so your assertions don't break when the serialiser changes insertion order.

fingerprint

JSON Hashing & Signing

Cryptographic operations on JSON require a canonical form. Sorting keys before hashing or signing ensures the same JSON always produces the same hash.

compare_arrows

Before JSON Comparison

Sort both JSON documents before comparing them to eliminate key-order differences from the diff — making it easier to spot genuine data changes.

menu_book

Documentation & Schemas

Alphabetically sorted JSON Schema properties and OpenAPI spec objects are easier for developers to scan, navigate, and maintain.

sync

Cross-Environment Normalisation

When JSON is generated by different services or languages, key order varies. Sorting normalises all outputs to a single canonical form.

JSON Sorter vs JSON Formatter vs JSON Compare

Three tools that work well together — sort, then format, then compare.

FeatureJSON SorterJSON FormatterJSON Compare
Primary purposeSort object keys A→Z or Z→AAdd indentation & whitespaceFind differences between two JSON
Changes key order✓ Yes (alphabetically)✗ No✗ No
Changes values✗ No✗ No✗ No
Recursive operation✓ Yes (all nesting levels)✓ Yes✓ Yes
Input count1 JSON document1 JSON document2 JSON documents
Best forNormalising key orderReadability & formattingChange detection & auditing
sort

Deep Recursive Sort

Keys are sorted at every nesting level — not just the top level. Every object in the entire document is alphabetised, including objects inside arrays.

verified

Values Unchanged

Only key order changes. All values, arrays, nested objects, and data types are preserved exactly as they are in the source JSON.

swap_vert

Ascending & Descending

Sort keys A→Z for the most common use case, or Z→A when reverse alphabetical order is needed for a specific convention.

verified

JSON Has Errors? Validate First

The sorter requires valid JSON. If sorting fails, use our JSON Validator to find the syntax error, or our JSON fix guide for common repairs.

Validate JSON

Frequently Asked Questions

Does sorting JSON keys change how parsers read the data?

No. JSON objects are unordered by specification (RFC 8259). A parser treats {"b":2,"a":1} and {"a":1,"b":2} identically. Sorting only affects the textual representation, not the data.

Why sort JSON keys before committing to Git?

Without consistent key order, two semantically identical JSON objects can produce different diffs because keys may be inserted in different orders by different tools. Sorted keys produce stable, minimal diffs.

Are arrays sorted too?

No. Only object keys are sorted alphabetically. Array elements remain in their original order because arrays are ordered sequences where position is semantically significant.

Does sorting work recursively on deeply nested objects?

Yes. The sorter processes every object at every depth level — inner objects, objects inside arrays, and nested objects inside nested objects are all sorted.

Can I sort JSON keys in descending order?

Yes. Use the Z→A toggle to sort in descending alphabetical order. This reverses the key order at every nesting level throughout the document.

Is this JSON sorter free?

Completely free with no account required. All sorting runs locally in your browser — your JSON data is never uploaded to any server.

Go Deeper

Related JSON Learning Resources

verified_user

About This Tool

Built by OpenFormatter · Last updated

sortRecursive sort at all nesting levels
lock100% browser-based — zero uploads
starFree forever, no account needed
JSON Sorter Online – Sort JSON Keys Alphabetically Free