{{ summaryFigure }}
{{ summaryDetail }}
{{ statusBadge }} {{ keyOrderBadge }} {{ scopeBadge }} {{ formatCount(analysis.metrics.keyCount) }} keys {{ duplicateKeyRows.length }} duplicate key note(s)
JSON sorter inputs
Choose strict JSON unless you are normalizing a human-edited config draft.
Paste one JSON value or load one .json, .jsonc, or .txt file.
{{ sourceMetaLabel }}
{{ sourceActionHint }}
Sort object member names while preserving values and normal array order unless array sorting is enabled below.
Use recursive sorting for stable diffs across nested configuration and API payloads.
Pick code-unit ordering for reproducible fixtures and signature-adjacent review.
Default keeps arrays unchanged while still sorting object keys inside array items.
Example: id, name, priority, or meta.rank.
Whitespace is regenerated after sorting, so source indentation does not carry over.
Use 0 to 10 spaces.
spaces
Duplicate names are scanned before parsing because sorted output cannot preserve overwritten values.
Turn on when the downloaded file should end with a newline.
{{ ensure_newline ? 'On' : 'Off' }}
Show 25 to 500 path rows in the table preview.
rows
{{ sortedJson || sortedFallbackText }}
Check Value Detail Copy
{{ row.check }} {{ row.value }} {{ row.detail }}
Path Change Before After Detail Copy
{{ row.path }} {{ row.change }} {{ row.before }} {{ row.after }} {{ row.detail }}
The selected order rules did not change any object or array order.
Path Pointer Type Depth Preview Copy
{{ row.path }} {{ row.pointer }} {{ row.type }} {{ row.depth }} {{ row.preview }}
Sort a valid JSON document to populate the path ledger.
{{ resultJson }}
Customize
Advanced
:

JSON object member order usually has no business meaning, but text order still matters when people compare files, review fixtures, prepare examples, or keep configuration changes readable. Sorting object keys creates a repeatable view of the same parsed data so diffs are easier to inspect and accidental reorder noise is easier to remove.

Key sorting should be treated as a review and formatting step, not as proof that the data is correct. Duplicate member names, parser differences, number serialization, and optional array sorting can all change what a receiving system sees. Strict JSON is the safer interchange target; cleanup mode is for human-edited drafts that need comments and trailing commas removed before standard JSON output is produced.

JSON object keys sorted into repeatable order, followed by audit, path, and depth review

Arrays need extra care because array order is data, not just presentation. Preserving arrays keeps event lists, priority lists, and ordered samples intact. Sorting arrays by a property is useful only when the array contains records and the chosen property is the real order key.

A stable sorted file is best used with the audit, order-change, and path views. The sorted text answers how the data will look after reserialization; the review rows explain what changed, what was counted, and where duplicate or structural surprises remain.

How to Use This Tool:

Start with the parser mode, then choose the ordering rules before trusting the sorted text.

  1. Set Parser mode. Use Strict JSON for normal interchange data. Use JSONC cleanup only for draft configuration text where comments or trailing commas need to be removed before standard JSON output.
  2. Paste into JSON source, browse for a .json, .jsonc, or .txt file, drop one file onto the editor, or load Sample. File loading is limited to files smaller than 2 MB.
  3. Choose Key order, Sort scope, and Key comparison. A-Z keys, Recursive object keys, and Unicode code-unit order are the best default for repeatable review.
  4. Leave Array handling on Preserve array order unless records in an array should be reordered by a field such as id, name, priority, or meta.rank.
  5. Pick the Output format. Two spaces, four spaces, tabs, compact output, and a custom 0 to 10 space indent are available. Use End newline when the downloaded file should end with a final line break.
  6. Open Advanced when duplicate keys or path-preview size matter. Warn and sort reports repeated names, Block sorted output stops output when repeated names are found, and Ignore duplicate notes hides those warnings.
  7. Review the summary and result tabs. Sorted JSON is the formatted result, Sort Audit explains the parse and sort status, Order Changes lists the object or array paths whose order changed, Path Ledger lists paths and pointers, and Key Depth Chart shows structure by depth.

If the status says the input needs attention, fix the parser message first. If duplicate keys are blocked, remove or rename the repeated object member before relying on the sorted output.

Interpreting Results:

Sorted JSON is the reserialized value after parsing, key ordering, optional array ordering, indentation, and final newline settings. A result with 0 objects reordered can still be useful because it confirms the source was already in the selected order.

Sort Audit is the best confidence check before copying. It records parse status, key order, objects scanned and changed, array policy, structure size, payload size, cleanup notes, and duplicate-key details when they are not ignored.

Order Changes shows the exact object or array paths where sorting changed visible order, with before and after key or sort-value previews for review.

Path Ledger helps verify that the shape is still the one you expected. Paths use dot and bracket notation for quick reading, while pointers use slash-prefixed JSON Pointer notation for systems that already use that standard.

The false-confidence warning is repeated object names. Standard parsing can keep only the last value for a duplicate name before sorting, so a clean-looking sorted object may already have lost an earlier value. Use the duplicate-key policy and audit rows before treating the output as a safe handoff file.

Technical Details:

A JSON object is a collection of member names and values. JSON itself does not assign meaning to object member order, while arrays remain ordered sequences. Key sorting is therefore a text-normalization choice for objects, not a general statement that the data is more correct.

Deterministic sorting depends on the comparison rule. Unicode code-unit ordering compares raw string units without language collation, which makes it better for repeatable fixtures and signature-adjacent review. Case-insensitive and natural number-aware ordering are easier for humans to scan, but they are not a substitute for a formal canonical JSON rule required by another system.

Transformation Core:

JSON sorting transformation stages
StageRuleReview Point
Prepare sourceStrict mode parses the text as standard JSON. Cleanup mode removes JavaScript-style comments and trailing commas before parsing.Cleanup notes appear in Sort Audit, and output is still standard JSON.
Parse valueThe source must produce one JSON value: object, array, string, number, boolean, or null.Syntax failure stops sorted output and reports the parser message, with line and column when available.
Scan duplicate namesRepeated object member names are detected before parsing overwrites earlier values.Duplicate key policy decides whether repeated names warn, block, or stay hidden.
Sort object keysObject member names are sorted A-Z or Z-A at the selected scope.Objects sorted and objects changed are counted separately, and changed paths appear in Order Changes.
Handle arraysArray order is preserved by default. Record arrays can be sorted by a property when enabled.Array sorting should be used only when that property defines the intended order.
Serialize outputThe parsed value is written back as compact, indented, tab-indented, or custom-space JSON.Whitespace is regenerated, and the custom space count is capped at 10.
Walk structureThe sorted value is counted by nodes, objects, arrays, scalars, keys, and depth.Path Ledger and Key Depth Chart come from the sorted structure.

Ordering Rules:

JSON key and array ordering rules
ChoiceBehaviorConsequence
Unicode code-unit orderCompares key strings by their raw code-unit values, then applies A-Z or Z-A direction.Most repeatable for diffs, fixtures, and canonicalization-style review.
Case-insensitive orderCompares keys without case sensitivity first, then uses the original string as a tie-breaker.Useful for reading mixed-case keys, but not a strict canonical order.
Natural number-aware orderCompares embedded numbers as numbers where possible, so names such as item2 can sort before item10.Better for human labels and generated field names.
Recursive object keysSorts each object found at any depth, including objects inside arrays.Best for whole-document diffs and nested configuration review.
Top-level object onlySorts only the root object when the root is an object.Preserves nested object member order for examples where inner order is intentional.
Property array sortingSorts eligible arrays of objects by a plain property or dot path. Missing or null values sort after matched values.Changes data order, so it should be reserved for arrays that are unordered record sets.

Path and Pointer Evidence:

Path ledger output meanings
Ledger FieldMeaningUse It For
PathA readable dot or bracket path such as $.alpha.channels[0].name.Finding values quickly while reviewing nested output.
PointerA JSON Pointer string where each token is prefixed by /, with ~ and / escaped inside tokens.Matching paths used by JSON Patch, schemas, or systems that report pointer-style locations.
TypeThe JSON value kind at that location: object, array, string, number, boolean, or null.Checking whether a field changed shape after cleanup or sorting.
DepthThe nesting level from the root value.Spotting unexpectedly deep data that may be hard to review or flatten later.
PreviewA compact summary of the value, such as object keys, array length, or short scalar text.Confirming the path points to the intended part of the document.

Do not treat the sorted output as a cryptographic canonical form unless the receiving system requires the same duplicate-key handling, Unicode ordering, array policy, number serialization, whitespace, and string escaping rules. A full canonicalization standard can be stricter than a review-oriented sorter.

Privacy Notes:

Pasted text and browsed or dropped files are read, parsed, sorted, charted, copied, and downloaded in the browser during the current session. No server lookup is needed for the sorting or path review itself.

Worked Examples:

An API configuration sample starts with keys in the order zebra, alpha, release, and limits. With A-Z keys, Recursive object keys, and Unicode code-unit order, Sorted JSON places object members in repeatable order at every depth, and Sort Audit reports how many objects were scanned and changed.

A wrapper object needs only its top-level keys cleaned up for a readme example. Choose Top-level object only so the root order changes while nested example objects keep their original member order. Path Ledger still lists the nested values so you can confirm the shape did not change.

A root array contains records with rank values. Switch Array handling to Sort root array by property and set Array sort property to rank. The summary names the number of arrays reordered; if a record has no rank, it sorts after records with a value.

A source object contains {"id":1,"id":2}. In warning mode, Sort Audit lists the duplicate key and sorted output keeps the parsed last value. In blocking mode, sorted output is withheld until the repeated name is fixed.

FAQ:

Does sorting JSON keys change the data?

Sorting object member names changes text order, not the parsed values. Array sorting is different because arrays are ordered data, so keep Preserve array order unless the array is a record set that should be sorted by a property.

Why did comments disappear from JSONC cleanup output?

Cleanup mode removes comments and trailing commas before parsing, then writes standard JSON. Comments and draft-only commas are not part of the final JSON value.

Which key comparison mode should I use for repeatable diffs?

Use Unicode code-unit order with the same A-Z or Z-A direction every time. Case-insensitive and natural ordering are easier to read in some documents, but they are review choices rather than strict canonical ordering.

Why does the duplicate-key warning matter?

A parser can keep only one value for a repeated object member name. The warning tells you the sorted text may already have lost an earlier value, so remove or rename the duplicate before using the output for handoff.

Does the sorter send my JSON anywhere?

The source text and selected file are handled in the browser for sorting, audit rows, the path ledger, and chart output. The tool does not need a server lookup to process the JSON document.

Glossary:

Object member
A JSON object name and value pair, often called a key and value in everyday use.
Unicode code-unit order
A deterministic string comparison based on raw code-unit values rather than human language collation.
JSONC cleanup
A draft-input mode that removes comments and trailing commas before standard JSON parsing.
Duplicate key
A repeated object member name inside the same object.
Order Changes
The result table that lists object or array paths whose visible order changed during sorting.
JSON Pointer
A slash-prefixed path syntax for identifying a value inside a JSON document.
Path Ledger
The result table that lists paths, pointers, value types, depth, and previews for the sorted structure.
Key Depth Chart
The chart that groups keys, objects, arrays, and scalars by nesting depth.