JSON Key Sorter

Sort JSON object keys recursively in case-sensitive lexical order while preserving array positions and value types.

Your JSON stays in this browser. Input is not uploaded.

Up to 200,000 input characters, 20,000 values and 64 nesting levels. Duplicate keys, unsafe integers, nonfinite numbers and nonzero numbers that underflow to zero are rejected. Decimals use JavaScript floating-point precision; formatting and numeric spelling may change.

Object keys sort by UTF-16 code units at every depth, including objects inside arrays. Array order stays unchanged. Numeric-looking keys sort lexically; this is not a cryptographic canonicalization scheme.

Sort keys without moving array items

Use this tool to make object key order predictable when reading configuration or comparing API examples. Paste valid JSON and choose Sort object keys. Every object is sorted recursively, including objects stored in arrays. Arrays retain their original item order. Scalars are accepted and returned as JSON values with normalized spelling.

Example: nested keys and numeric-looking names

The built-in example contains keys z, a, 10 and 2. The output puts 10 before 2, then a, then z. Inside a, the key a comes before b. Sorting uses case-sensitive UTF-16 code-unit order, not numeric order, locale collation or natural sorting. For an array such as [{"z":1,"a":2},3], the first item's keys change order while the number remains second.

What changes in the output

Indentation becomes two spaces. Whitespace, escape spelling and number notation may normalize, but strings are not trimmed or case-folded. Duplicate object keys are rejected instead of silently retaining one value. Keys named __proto__ remain ordinary data. The serializer writes sorted keys directly, so JavaScript's usual reordering of integer-like property names does not override the requested lexical order in the downloaded text.

This is not signature canonicalization

Deterministic key order alone is insufficient for signing documents or implementing a canonical JSON standard. This tool does not claim RFC 8785 compliance. JavaScript floating-point numbers can change decimal spelling and negative zero; unsafe integer and nonfinite values are refused, but arbitrary-precision decimal preservation is not provided. Keep long identifiers and exact monetary strings quoted, and use a purpose-built canonicalizer for cryptographic protocols.

Input is limited to 200,000 characters, 20,000 values and 64 nesting levels. Formatted output is limited to two million characters. Invalid syntax, comments, trailing commas and duplicate keys produce errors without changing your input. Copy or download the result after checking the ordering; changing input clears stale output. Processing happens locally in the browser.

For extracting a single branch instead of reordering it, use JSON Pointer Resolver. To compare repeated array values independently of their object key order, use JSON Array Deduplicator. Sorting keys does not remove duplicates from arrays or repair invalid JSON.

Nonzero numbers too small to remain nonzero in JavaScript, such as 1e-400, are rejected rather than silently becoming zero.