Skip to main content
WizTools123
WizTools123
Free Online Tools

Tool Categories


JSON Tools New Tool

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.

Free Forever Nothing Uploaded Three keys at once Many files at once
Free Online JSON Array Sorter
Share this tool
Advertisement Slot (Top Banner) Google AdSense Unit • Responsive Banner
JSON Array Sorter Your file is read inside this tab. Nothing is uploaded anywhere.
Drop the JSON files you want sorted Or paste one below. Every array in the document is found for you. Choose files Up to 15 MB per file. Nothing is uploaded.
0%
Or paste it
Reading
Which array
Sort by
Then by
And then by
Details
Writing

0 items - compared as 0 missing the key 0 dropped

Sorted
0 characters 0 lines 0 B
Buy Us A Coffee

Enjoying WizTools123? Help keep our server infrastructure 100% free and open for everyone.

Buy Us A Coffee
Sponsored Content (Below Tool) Google AdSense Placement

How to Sort a JSON Array

A few steps, and nothing is uploaded.

1
Paste the JSON, or drop the files Every array in the document is found and listed with its size, so you can pick the one you meant.
2
Choose the array The largest one is chosen to start with, since that is usually the list of records. A top level array is picked automatically.
3
Name the key, or a nested one Keys found in the records are suggested as you type. A nested key is written with a dot, as customer.name.
4
Add a second and third key if you need them They only decide where the first key ties. Take the result from the right, or download every file as a zip.

What to Know About Sorting

Types, blanks, and why the order of equal items matters.

Items with the key missing always go last. Not first in descending order, last in both. Sorting is something you do to look at the top of a list, and a page of blanks at the top is never the answer. The count tells you how many items were missing the key, which is often the more useful thing to know anyway.
The sort is stable, which is what makes a second key work. Two items that compare equal keep the order they came in, so sorting by total and then by date leaves items with the same total in date order. An unstable sort would shuffle them, and the second key would do nothing you could rely on.
Text and number order are both correct and they disagree. As text, "10" comes before "9", because comparison is character by character. As numbers, 9 comes first. Neither is a bug. The type is detected from the values and shown to you, and it can be overridden when the detection is not what you wanted.
Natural order is for references with numbers in them. A-2, A-9, A-10, A-100 is what a person expects; as plain text it comes out A-10, A-100, A-2, A-9. Natural order reads the digit runs as numbers and the rest as text, which is the behaviour of a well made file manager.
Dates are compared as dates, not as strings. That matters because an ISO date happens to sort correctly as text while almost every other format does not. Anything the browser can read as a date is handled, and a value it cannot read is treated as missing rather than being silently placed at one end.
Only the array you chose changes. The rest of the document comes out byte for byte the same, apart from the indent and key order you asked for in the writing options. Nothing is added, removed or reformatted elsewhere.
Dropping repeats compares the sort keys, not the whole record. So two records with the same reference are treated as the same item even if a timestamp differs, and the first one in the sorted order is the one kept. That is the useful behaviour for cleaning a list of records, and it is off by default because it removes data.

Key Features & Capabilities

What this tool does, and what it deliberately does not.

Finds the arrays for you Every array in the document is listed with its size, so you do not have to write a path.
Three keys at once Each with its own direction and type, and the later keys decide only where the earlier ones tie.
Nested keys work Write customer.name to sort records by a value one level down, and keys are suggested as you type.
Dates as dates Real date comparison rather than string comparison, which only happens to work for ISO dates.
Stable and predictable Equal items keep their order, and items missing the key go last in either direction.
Many files at once Set the keys once, drop a folder of files in, and download every sorted result as one zip.

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.

Yes. Every array in the document is found and listed with its path and size, and the largest is selected to begin with, since that is usually the one you want. Picking a different one changes nothing else in the document.

Write the key with a dot, as customer.name. Keys found in the records are suggested as you type, including nested ones, so usually you can pick from the list rather than typing a path.

At the end, in both ascending and descending order, because the point of sorting is to look at the top of the list. The count of how many were missing the key is shown next to the result.

Because they were compared as text, where comparison is character by character and 1 comes before 2. Choose natural order and you get A-2, A-9, A-10, A-100, which reads the digit runs as numbers.

It decides the order of items the first key ties on, and nothing else. The sort is stable, so a third key works the same way. If the first key is unique across the records, the later keys will have no visible effect.

No. Only the items of the array you chose are reordered. The indent and key order settings apply to the whole document when it is written back out, as they do on every tool here, and nothing else is altered.

Other JSON Tools

Advertisement Slot (Bottom Banner) Google AdSense Unit • Responsive Banner