JSON Sorter – sort object keys

Sort JSON object keys A → Z or Z → A at every nesting level in your browser. Array item order is kept. Indentation is presentation, not the sort. Nothing is uploaded.

Last updated: October 2, 2026

Tool

This tool will load here.

What JSON sorting does

A JSON sorter reorders object keys. It does not change values. After a successful JSON.parse, every object — including objects nested inside other objects and inside arrays — gets a deterministic key order. The array itself stays in the same item order. This JSON Sorter runs in the browser. Nothing is uploaded.

That is a different job from a JSON formatter. A formatter controls whitespace and indentation so the text is easier to read. Sorting changes which key comes first. This page prints indented output so you can see the new order; that indentation is presentation only. If you only want pretty-print and want to keep the original key order, use the JSON Formatter instead.

Developers sort JSON when they need a stable shape: a Magento or WordPress config dump in git, two API bodies to compare by eye, or a payload whose keys arrive in a different order on every request. JSON itself does not treat object member order as meaningful. Humans and diffs often do.

How to use

  1. Paste JSON. Empty input is not a value.
  2. Leave Sort order on Ascending A → Z, or switch to Descending Z → A.
  3. Choose Sort JSON. Example loads a nested object plus a users array. Copy output writes the sorted text. Clear empties both boxes.

Invalid JSON is not sorted. The status shows the browser parse error and the output box is cleared. Sorting always walks every nesting level. There is no “root only” switch, because a root-only sort would leave nested keys in a different order from the envelope and that is the usual source of confusion.

Example

This object is the example on the page:

{
  "name": "John",
  "users": [
    { "z": 1, "a": 2 },
    { "b": 3, "a": 4 }
  ],
  "age": 30,
  "meta": {
    "version": 1,
    "created": "2026-01-01"
  }
}

Ascending A → Z puts age first, then meta, name, users. Inside meta, created comes before version. The two user objects stay in the same array order; their keys become a then z, and a then b.

A flat object such as name, age, email becomes age, email, name when sorted A → Z. Values stay 30, the email string, and John.

Sorting vs formatting

Format answers “make this text readable.” Sort answers “put the keys in a stable order.” You can format without sorting, and you can sort and then minify. If you need a compact string after a sort, paste the output into the JSON Minifier. If you need to inspect nesting rather than rewrite keys, use the JSON Viewer. If you only need the field names, use the JSON Key Extractor.

Key order follows Unicode code-unit comparison. For ordinary English ASCII keys that is A–Z, then a–z. Descending reverses that comparison. The comparison does not try to be a locale-aware dictionary sort, because those rules differ by browser language.

Arrays and primitives

Array item order is data. This tool does not reorder array elements, does not sort by a child field, and does not implement JSONPath. Objects found inside arrays are still key-sorted. A root array is legal: items stay put; nested objects are sorted. A root string, number, boolean, or null has no keys; the output is the same value, indented for reading, with a status that says so.

Limits

  • JSON object order is not part of the JSON data model. Sorting is for people, diffs, and normalization, not for changing meaning.
  • Values are not rewritten. Numbers stay numbers. Strings stay strings, including text that looks like HTML.
  • JSON.parse owns the value. Duplicate keys in the source text cannot be preserved; the last property wins in the browser.
  • Traversal stops after 4000 nodes. The output is then cleared. There is no half-sorted document.
  • Comments, trailing commas, and single quotes fail the same way they fail the JSON Validator.

After you sort both sides, compare values with how to compare two JSON documents.

Privacy

Parse and sort run in this browser. The payload is not sent to YallaSolve for this tool. Clear the tab if you pasted customer fields.

On this page

Related Articles

Related guides

Related solutions

Need another tool ?

Open the free tools — no signup.

FAQs

newsletter signup

Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Innovative Solutions For Modern Needs
Copyright © 2026 Yallasolve. all rights reserved.