Loading JSON Array Sorter...
Please wait a moment

How to Sort JSON Arrays - Step by Step Guide

Step 1

Input Your JSON Array

Start by providing your JSON array! Whether you're working with arrays of objects, primitive values, or need to format JSON first, you have several convenient options for sorting JSON data:

•
Paste directly: Copy your JSON array and paste it into the input editor
•
Upload a file: Click "Upload" to select a .json or .txt file from your computer
•
Try the sample: Click "Sample" to load example data and see how the sorter works

Example: Unsorted JSON Array

Here's an example of an unsorted JSON array with employee data. Notice how the items are in random order:

[
  {
    "name": "Charlie",
    "age": 42,
    "salary": 82000
  },
  {
    "name": "Alice",
    "age": 28,
    "salary": 95000
  },
  {
    "name": "Bob",
    "age": 35,
    "salary": 75000
  }
]

Tip: You can also sort primitive arrays like ["banana", "apple", "cherry"] or [100, 5, 50, 25] without selecting a key.

Step 2

Choose Sort Options

Once your JSON array is loaded, the tool automatically detects available keys. Customize your sorting:

•
Select sort key: For arrays of objects, choose which property to sort by (e.g., "name", "age", "salary")
•
Choose direction: Select ascending (A-Z, 0-9) or descending (Z-A, 9-0) order
•
Automatic sorting: The output is re-sorted as soon as you change the key or the direction

Example: Sorted by Salary (Descending)

The same array, sorted by salary in descending order (highest to lowest):

[
  {
    "name": "Alice",
    "age": 28,
    "salary": 95000
  },
  {
    "name": "Charlie",
    "age": 42,
    "salary": 82000
  },
  {
    "name": "Bob",
    "age": 35,
    "salary": 75000
  }
]

💡 Pro Tip: For arrays of objects, the tool automatically detects all available keys. You can sort by any property like "name", "age", "salary", "department", etc. Numbers are sorted numerically (not alphabetically), so 100 comes after 9, not before it.

Step 3

View Sorted Results

The sorted array appears in the output panel, indented with two spaces, ready to paste into APIs or databases:

•
No sort button: The result updates by itself a moment after you stop typing or change an option
•
Where gaps go: Items with a null value, or without the chosen key, are always placed at the bottom, whichever direction you pick
•
Equal values: Items that tie keep the order they had in your input
•
Values as typed: Each item is copied from your input, so nested objects, long IDs like 8901240544102066246 and decimals like 14.50 come out unchanged

Example: Sorting by Different Keys

You can sort by any key in your objects. Here are examples of sorting the same array by different properties:

Sort by Name (Ascending)
"Alice", "Bob", "Charlie"
Sort by Age (Descending)
42, 35, 28
Step 4

Export Your Sorted Array

Once the order looks right, take the result with you:

•
Copy to clipboard: Copies exactly what the output panel shows, ready to paste into your code editor or an API request
•
Download as file: Save as a .json file for later use, version control, or sharing with your team. The file maintains proper formatting
•
Use with other tools: The sorted output can be used with JSON to CSV, JSON to Table, or JSON Array Filter for further processing

Example: Use Cases for Sorted Arrays

📊 Data Analysis

Sort sales data by revenue, customer lists by name, or product catalogs by price for easier analysis

🎯 API Responses

Sort API response arrays before displaying in your frontend application for better user experience

📈 Reports

Prepare sorted data for reports, dashboards, or presentations with consistent ordering

🔍 Database Prep

Sort arrays before importing into databases or exporting to spreadsheets for organized data

Frequently Asked Questions

How do I sort a JSON array?

Paste the array into the input editor (or upload a .json file). For a list of objects, pick the key to sort by from the Sort by menu; it lists every key that appears in any of the objects, not just the first one. Then choose Asc or Desc. A list of plain values, like [3, 1, 2] or ["pear", "apple"], is sorted by the values themselves, so you only pick the direction. The result updates a moment after you stop typing.

Where do mixed values, null and missing keys end up?

In ascending order numbers come first, then text, then false and true, then objects and arrays. Descending reverses that. Items whose value is null, objects that don't have the chosen key at all and entries that aren't objects always go to the bottom, in both directions, so the gaps never get mixed in with your real values. Objects and arrays used as sort values keep their original order among themselves.

Are numbers sorted by value, and do long IDs stay exact?

Numbers are compared by their exact value, so 100 comes after 9, -0.5 before 9, and IDs like 8901240544102066246 and 8901240544102066247 land in the right order even though they are too long for a normal JavaScript number. The items themselves are copied from your input, so 14.50, 1e21 and escapes such as "\u0041" come out exactly as you typed them. Numbers written in quotes, like "10" or "00501", are text and sort as text, which puts "10" before "9".

How is text compared?

Upper and lower case are ignored, and letters are compared by their Unicode code point. That means "apple" and "Apple" count as equal, and accented letters such as é sort after z rather than next to e. Dates written the ISO way (2024-01-15 or 2024-01-15T08:30:00Z) sort in date order, because they put the year first.

What happens to items with the same value, and can I sort by two keys?

Items with equal values stay in the order they had in your input. That also gives you a way to sort by two keys: sort by the less important key first, paste the result back in, then sort by the main key. The earlier order survives inside each group.

Can I sort by a nested key, or sort an array inside an object?

The Sort by menu offers the top-level keys of the objects; a nested path such as address.city isn't available. Nested objects inside each item are carried along unchanged. If you paste an object instead of an array, for example an API response like {"users": [...]}, the first list inside it is sorted in place and everything around it is left alone; a note above the output tells you which list that was.

Is my JSON uploaded anywhere?

No. The sorting runs in your browser and the JSON isn't sent to our server. Nothing is kept either: reload the page and the editor starts empty.

Need to narrow the list down first? Try the JSON Array Filter, or turn the sorted result into a table for easier reading. For how JavaScript itself sorts arrays, see Array.prototype.sort on MDN.