UTILS.
100% in-browser
A↓}

JSON Key Sorter

Recursively sort the keys of a JSON object, ascending or descending.

— output appears here —

About this tool

JSON Key Sorter is a free, in-browser tool that walks a JSON document and sorts every object's keys into a predictable order. Paste your JSON, click Format, and it parses the text with the browser's own JSON engine, recursively sorts each nested object's keys, and prints the reordered result. Arrays keep their original order; only the keys inside objects move.

Keys are ordered lexicographically by character code, so uppercase letters sort before lowercase and numeric-looking keys sort as text; tick Descending to reverse it. Output can use 2- or 4-space indent, a tab, or a minified single line, with a Copy button for the result.

Everything runs client-side, so nothing is uploaded and it works offline — no accounts, no tracking. Sorting keys the same way every time keeps diffs stable and config files easier to scan.

Frequently asked questions

Are array elements reordered?
No. Arrays keep their original order — only object keys are sorted. Sorting is recursive, so it reaches nested objects, including objects stored inside arrays.
Can I control the indentation?
Yes. Pick 2 or 4 spaces, a tab, or minify to a single line; changing the indent updates the output immediately.
What order are the keys sorted in?
Keys are compared as strings by character code, the JavaScript default, so uppercase sorts before lowercase and numeric-looking keys sort as text (item10 before item2). Enable Descending to reverse the order.
What if my JSON is invalid?
The text is parsed in your browser and an invalid-JSON error shows until the syntax is valid. Nothing is uploaded; fix the input and click Format to sort it again.

More tools