JSON Sort
Sort a JSON array of objects by any field — ascending or descending. Auto-detects numeric vs string sorting.
Sort JSON Arrays by Any Field
JSON Sort lets you sort a JSON array of objects by any field — ascending or descending. Paste your array, pick a field from the auto-populated dropdown, and the sorted output appears instantly. The tool auto-detects whether a field contains numbers or strings and applies the right comparison: numeric subtraction for numbers, localeCompare for strings. Missing or null values are treated as an empty string, so they sort first in ascending order and last in descending order.
Nested fields are supported using dot notation — for example, address.city sorts by the city property inside an address object. The dropdown automatically lists all top-level and shallow-nested keys found in the first array element. The original array is never mutated — sorting produces a new copy. Runs entirely in your browser; no data is sent to any server.
Example
Input — unsorted array of users:
[
{ "name": "Charlie", "age": 32, "score": 88 },
{ "name": "Alice", "age": 28, "score": 95 },
{ "name": "Bob", "age": 35, "score": 72 }
]Sorted by score, descending:
[
{ "name": "Alice", "age": 28, "score": 95 },
{ "name": "Charlie", "age": 32, "score": 88 },
{ "name": "Bob", "age": 35, "score": 72 }
]Where JSON Sort Helps
- ▸Reviewing an API response — Sort a paginated list by date, price or score to eyeball outliers before writing any code.
- ▸Preparing test fixtures — Produce a deterministically ordered fixture so snapshot tests and diffs stay stable across runs.
- ▸Leaderboard / ranking data — Sort scores or rankings descending without spinning up a script for a one-off task.
- ▸Cleaning up exported data — Reorder records exported from a database or spreadsheet before sharing or re-importing them.
Sorting a JSON Array in Code
JavaScript:
const sorted = [...array].sort((a, b) => {
const av = a.score, bv = b.score;
return typeof av === "number" && typeof bv === "number"
? bv - av // descending, numeric
: String(bv).localeCompare(String(av));
});Python:
sorted_items = sorted(items, key=lambda x: x["score"], reverse=True)