Sort a JSON Array
Sort the elements of a JSON array in place: numerically for numbers, alphabetically otherwise, or by one field of each object.
What sorting a JSON array does
The top-level array is reordered and nothing else changes: objects keep their key order, strings keep their escaping, and the array length is never altered. Numbers compare numerically, so 2 comes before 10; everything else compares as text with a locale-aware collation. When a key is given, each element is expected to be an object and that field is compared instead; an element without the field sorts after every element that has it, in both ascending and descending order, because a missing value is not a small value.
How to use it
Sort a JSON Array: paste the JSON array into the box above, set Sort objects by key (default blank), Order (asc or desc), default "asc" and Indent (default 2), and press Run to get the sorted array below.
Worked example
Input:
[
"banana",
"apple",
"cherry",
"date"
]
Output:
[
"apple",
"banana",
"cherry",
"date"
]
Why it runs in your browser
The conversion happens on this page with JavaScript. Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere. The page reads JSON array and returns sorted array; reloading the page discards both.
The top-level array is reordered and nothing else changes: objects keep their key order, strings keep their escaping, and the array length is never altered. Numbers compare numerically, so 2 comes before 10; everything else compares as text with a locale-aware collation. When a key is given, each element is expected to be an object and that field is compared instead; an element without the field sorts after every element that has it, in both ascending and descending order, because a missing value is not a small value.
Sort the elements of a JSON array in place: numerically for numbers, alphabetically otherwise, or by one field of each object.
How to use it
Sort a JSON Array: paste the JSON array into the box above, set Sort objects by key (default blank), Order (asc or desc), default "asc" and Indent (default 2), and press Run to get the sorted array below.
Why it runs in your browser
The conversion happens on this page with JavaScript. Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere. The page reads JSON array and returns sorted array; reloading the page discards both.
What to Expect
Best for
- Converting JSON array to sorted array when the data is already on screen.
What this tool keeps
- Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere.
Sample input
[ "banana", "apple", "cherry", "date" ]
Sample output
[ "apple", "banana", "cherry", "date" ]
Frequently asked questions
How do I use the sort a json array?
Sort a JSON Array: paste the JSON array into the box above, set Sort objects by key (default blank), Order (asc or desc), default "asc" and Indent (default 2), and press Run to get the sorted array below.
Is my input uploaded?
No. The text is parsed on this page with JavaScript and is never posted to a server.
Is there a size limit?
Yes: 5 MB per run. Larger input is refused with a message rather than freezing the tab.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.