Skip to content
Input
Text
Limit
1 MiB
Runtime
Browser

Sort JSON object keys for deterministic review

Create a predictable object-member order for snapshots, reviews, and fixtures without changing arrays or evaluating the document.

Local processingNo sign-upNo share URL

Sort JSON keys

Inputs are limited to 1 MiB and stay in this browser tab.

Paste or edit the source. Tool Swim does not upload or save it.

Sorted JSON

Nothing is placed in a URL, account, or remote log.

What this tool does

Strict, bounded, local processing

Sorting is an explicit presentation transform. Recursive mode visits nested objects; top-level mode leaves nested member order untouched.

Deterministic order makes generated artifacts easier to inspect

Object member order is often incidental to the application consuming JSON. When two serializers produce the same members in different orders, a text diff can show broad churn even though the represented data is equivalent. Sorting member names provides one stable presentation for review and fixture generation.

Tool Swim compares names with the browser's locale-independent string ordering used by the implementation and serializes the result with two-space indentation. The transform is deterministic for the same runtime and input. It is not a standards-defined canonical JSON format or a cryptographic normalization scheme.

Array order is preserved because it carries meaning

An array represents an ordered sequence. Sorting its elements could change priority, chronology, coordinates, test expectations, or a consumer's interpretation. This tool visits object values inside arrays in recursive mode, but it never rearranges the array positions themselves.

If an application treats one particular array as a mathematical set, define that domain rule in application code and test it with a stable key. A generic browser tool cannot infer whether two objects are safe to reorder or how duplicates should be handled.

Do not use sorting as a signature algorithm

Signing and hashing protocols require an exact canonicalization specification that covers numbers, Unicode, escaping, and member order. An alphabetical pretty-printer does not meet that contract. Follow the named canonicalization algorithm required by the protocol and use its conformance tests.

For ordinary code review, sorting can still reduce noise. Keep the unsorted source when its grouping helps authors, and generate the sorted artifact at a documented boundary so future contributors understand why the order changed.

Primary standards

Questions and answers

Related JSON tools

Related JSON guides