JSON Key Sorter

← All tools

Paste a JSON object and get the same values with the keys sorted. Arrays stay in the order you wrote them.

The JSON stays in the browser. It is not uploaded, and it is not stored in the URL. The URL keeps the options only when they are not the defaults.

Open file…

Files up to 1 MB open in the page. The page stops at 1,000,000 characters.

Not sorted

Sorted JSON

About this tool

The page parses with JSON.parse, sorts the keys of each object, and writes the value back with JSON.stringify. The default indent is two spaces. Minify writes one line. The root has to be an object. An array has no keys to sort, so an array root is rejected.

Case-sensitive order is JavaScript string order, which compares UTF-16 code units. Uppercase letters come before lowercase letters, so B comes before a. Turn case-sensitive off and the comparison uses toLowerCase, which is the Unicode default case mapping, not a locale. When two keys fold to the same letters, the original spelling breaks the tie, so the result does not depend on which key JSON.parse saw first.

Nested objects are sorted when that box is on. Turn it off and only the top object is sorted. Arrays keep their order either way, including objects inside an array, which are still sorted when nested sorting is on. JSON.parse keeps the last value when a key is repeated. This page cannot show the value that was overwritten.

Read more

Free books, courses, and software

Get my programming books, course editions, and complete software.

Get the download library →