Expected arrays to be sorted too
By default, arrays keep their original order.
Fix: Use a dedicated line sorter if you need array sorting as well.
header • up to 320x100 / 728x90
Recursively sort JSON object keys alphabetically while preserving array order
Output will appear here...
content bottom • up to 300x250
sidebar • 160x600
Last reviewed:
JSON (JavaScript Object Notation) is a lightweight, human-readable data format used almost everywhere on the web for APIs, config files, and log output.
JSON Sorter recursively walks through your JSON document and reorders every object's keys in alphabetical order, leaving array element order untouched.
It's a common prerequisite for producing canonical JSON used in hashing, signature verification, diffing, and source-control-friendly configuration files.
{
"name": "Ada",
"id": 7,
"roles": ["ops", "admin"]
}{
"id": 7,
"name": "Ada",
"roles": [
"ops",
"admin"
]
}By default, arrays keep their original order.
Fix: Use a dedicated line sorter if you need array sorting as well.
Different serialisers may still emit different whitespace.
Fix: Use both JSON Sorter and the formatter to normalise output.
No — only object keys. Arrays preserve their original order so semantics are not changed.
It uses Array.sort's default string comparison (code-point order).
Yes — every nested object is sorted.
Yes — invalid JSON returns an error message.
No — sorting is client-side only.
Pair the sorter with the fixer, cleaner, and formatter to produce canonical JSON. You can also browse the full Formatters & Beautifiers category for more options.
Format, validate, and beautify JSON online with readable indentation, syntax checking, and copy-ready output for APIs, logs, and config files.
Auto-repair common JSON errors — trailing commas, single quotes, unquoted keys, and comments
Strip comments, null values, and empty strings to produce compact, production-ready JSON
Collapse formatted JSON into a single compact line — great for config files and env vars
Flatten any JSON document into a list of JSONPath-style leaf paths and values
Validate JSON syntax and catch parse errors instantly. Paste JSON and get immediate feedback on structural issues, missing commas, and unquoted keys.
Sort sibling XML elements alphabetically by tag name while preserving attributes
Format raw environment variables into clean .env, export, JSON, or YAML output with normalized quoting and copy-ready key ordering.
Format Angular templates online with cleaner indentation and spacing for HTML, bindings, and interpolation blocks.
Transform and reformat JavaScript code using Babel parsers. Supports modern JS features, JSX, and experimental syntax. Get cross-compatible formatted output.
Format and beautify C code online with proper indentation and brace placement. Paste C code and get clean, readable output following standard C conventions.
Format and beautify C# code online with proper indentation and .NET coding style. Paste C# and get clean, readable output following best practices.