Sort the keys of a JSON recursively

Developers can use this while debugging or preparing data for an exchange, especially when the result needs a quick visual check. Sort the keys of a JSON recursively.

Sort the keys of a JSON recursively. The result appears instantly in your browser, ready to copy, with no account, upload or storage involved.

How to use

  1. Paste a JSON object into the input area or import a compatible text file.
  2. Pick A to Z for ascending alphabetical order, or Z to A for the reverse.
  3. Press the Sort button to recursively reorder all keys.
  4. Tick Sorted and minified if you want a compact version of the JSON.
  5. Retrieve the result shown in the right-hand area to use it elsewhere.

Example

You have a JSON with keys out of order, for example {"z": 1, "a": {"y": 2, "b": 3}}. After sorting, keys appear in alphabetical order at every level. This makes reading and comparing two files much easier.

Input

{"z": 1, "a": {"y": 2, "b": 3}}

Output

{
  "a": {
    "b": 3,
    "y": 2
  },
  "z": 1
}

Limits and formats

Where processing happens

Everything runs in your browser: the sort is performed locally without sending your data out. You can therefore handle configuration snippets or API responses with peace of mind.

Frequently asked questions

Is the sort case-sensitive?

Alphabetical sorting usually orders uppercase and lowercase according to character codes. For example, a key starting with an uppercase letter may appear before a lowercase key. Check the result if case matters to you.

Can I sort JSON that contains nested arrays?

Yes, sorting applies recursively to all objects, including those inside arrays. Array elements keep their order, but the keys of objects they contain are sorted.

What exactly does the Sorted and minified option do?

It sorts the keys and then removes spaces and line breaks to produce compact JSON. The result is harder for humans to read, but useful for reducing size before a transfer.

Tools in the same category