Free Online JSON Array Sorter
Sort any array inside a JSON document by up to three keys at once, comparing as text, numbers, dates, natural order or length. The sort is stable, so equal items keep their order and the second key still decides. Items missing the key go last in either direction, and the rest of the document is left exactly as it was.
Enjoying WizTools123? Help keep our server infrastructure 100% free and open for everyone.
How to Sort a JSON Array
A few steps, and nothing is uploaded.
What to Know About Sorting
Types, blanks, and why the order of equal items matters.
Key Features & Capabilities
What this tool does, and what it deliberately does not.
About Sorting JSON Arrays
Sorting an array of records sounds like the most basic operation there is, and the reason it is worth a tool is that the awkward cases are the normal cases. Real exports have records where the field you want to sort by is missing. They have reference numbers like A-9 and A-100 that no plain text sort will order sensibly. They have dates in formats that only accidentally sort as strings. And they have ties, which is where the second key you actually wanted comes in.
The missing field is the one that catches people out most often. Sorting ascending puts the empty ones first in most implementations, so the top of your list, which is the part you are looking at, is a page of nothing. Putting them last in both directions is the behaviour a spreadsheet gives you and it is almost always what you meant, so that is what happens here, and the number of items missing the key is reported rather than hidden.
Stability is the other quiet requirement. A stable sort keeps equal items in the order they arrived, which is exactly what makes sorting by one key and then another work: the second key only has to decide the ties the first one left. If the sort is not stable, the second key gets shuffled away and the result looks almost right, which is worse than looking wrong.
Everything else is about not surprising you. Only the array you chose is touched. The type being used for comparison is shown, because text order and number order are both correct and they give different answers. And the result updates as you change the keys, so you can see what a choice does rather than having to predict it.
Frequently Asked Questions
Nested keys, missing keys, dates and numbers.