Data & CSV

JSON Sort Keys

Sort JSON Keys Alphabetically

Sort the keys of every JSON object alphabetically, at every level.

About this tool

About JSON Sort Keys

Sorted keys make JSON easier to scan, review and compare. Two API responses with the same data but keys in a different order produce noisy diffs; sort both and the noise disappears. Config files, translation files and package manifests also stay tidier when every object is in alphabetical order. This tool sorts the keys of every object at every depth, including objects inside arrays, while the arrays themselves keep their original order because array order is part of the data. Choose A to Z or Z to A, turn on natural number order so item2 comes before item10, and decide whether uppercase and lowercase letters sort together or separately. Pick 2 spaces, 4 spaces, tabs or a minified single line for the output. The data is never changed, only the order keys are written in. Everything runs in your browser, so internal configs and payloads stay private.

Built and maintained by Abhi JainUpdated

How to Sort JSON Keys

  1. 1

    Paste JSON

    Paste JSON into the JSON pane or open a .json file.

  2. 2

    Choose the order

    Pick A → Z or Z → A, the indentation, and whether to use natural numbers or case-sensitive sorting.

  3. 3

    Copy the result

    Copy the sorted JSON or download it as sorted.json.

JSON Sort Keys: questions and answers

Does sorting keys change my JSON data?

No. JSON objects are unordered by definition, so any parser reads the sorted document as the same data. Only the written order changes.

Are arrays sorted too?

No. Array order is meaningful, so arrays keep their items in place. Objects inside arrays still have their keys sorted.

What is natural sort order?

Natural order compares numbers inside keys by value, so item2 comes before item10. Plain alphabetical order would put item10 first because 1 is smaller than 2.

Why do number-like keys stay first?

JavaScript always lists integer keys such as "1" and "2" before other keys in an object, whatever order they were added in. This is how every browser and Node.js behave.

Is my JSON uploaded?

No. Sorting happens in your browser.