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:

json
[
  { "name": "Charlie", "age": 32, "score": 88 },
  { "name": "Alice",   "age": 28, "score": 95 },
  { "name": "Bob",     "age": 35, "score": 72 }
]

Sorted by score, descending:

json
[
  { "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 responseSort a paginated list by date, price or score to eyeball outliers before writing any code.
  • Preparing test fixturesProduce a deterministically ordered fixture so snapshot tests and diffs stay stable across runs.
  • Leaderboard / ranking dataSort scores or rankings descending without spinning up a script for a one-off task.
  • Cleaning up exported dataReorder records exported from a database or spreadsheet before sharing or re-importing them.

Sorting a JSON Array in Code

JavaScript:

js
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:

python
sorted_items = sorted(items, key=lambda x: x["score"], reverse=True)

Frequently Asked Questions

No. Sorting always produces a new array; your pasted input is left untouched, so you can compare before and after.

Yes — enter or select a dot-notation path like address.city or user.profile.age. The tool walks the object at each level to find the value.

A missing or null value is treated as an empty string for comparison purposes, so those records sort to one end depending on ascending or descending order.

Not directly — this tool sorts by a single field. For multi-key sorts, sort by the secondary field first, then the primary field, since most sort implementations (including this one) are stable and preserve relative order for ties.

No. Sorting runs entirely in your browser using JavaScript's native Array.sort — nothing is sent to a server.

Related Tools