JSON Sort & Group
JSON Sort & Group reshuffles a JSON array by rules you pick. The redesigned workbench first scans and lists the target array and its fields: click a chip to set the sort or group field and the result updates live on the right. Sorting supports numeric values, natural text and drag-and-drop custom order; grouping offers flat-array and grouped-object output plus a structural preview for checking the result row by row.

:::tip 30-second quickstart
- Paste or drop JSON (an array, or an object that contains one)
- Click a field chip under Discovered fields — after picking Sort or Group as the click target
- Choose the sort strategy: Numeric / Text / Custom
- Optionally fill in Group field and pick the output shape and group order
- Copy or export the live result on the right :::
Workbench at a glance
- Left: input area → Target array → Discovered fields → Group field → Sort field / Custom order → Advanced settings
- Right: result area with a JSON / Preview switch plus Copy, Copy node and Export
- Input header: Format JSON, Upload and Clear all; the whole input card accepts dropped files
- Live results: there is no Start button — editing the JSON, clicking a field or changing an option recalculates instantly
How to use
1. Input JSON data
- Paste JSON, or drop a
.json/.txtfile anywhere on the input card; Upload works too - JSON5 syntax is accepted (comments, trailing commas, single quotes, unquoted keys)
- Format JSON re-indents the input with two spaces (disabled while the JSON is invalid)
- Clear all wipes the source, the target array, the field selection and the custom order
- Invalid JSON shows "Invalid JSON format" under the input and in the result pane
- When the JSON contains no sortable array, the tool reports "No sortable array found in this JSON. Provide an array or an object containing an array."
- With an empty input, the right pane offers three example cards — Sort by price descending, Group by category & sort by rating and Custom priority sequence — clicking one loads the JSON plus the whole configuration
2. Pick the target array and fields
Target array
- When the top level is an array, it is the sort target directly (path
$) and no selector is shown - When the top level is an object, the tool scans it for arrays and lists them in the Target array selector (path + item count), preferring arrays whose elements are objects
- A nested array such as
$.productsis replaced in place: the wrapper object is preserved in the output - An empty target array is reported as "Target array is empty" in the preview
From Discovered fields
- When the target array's elements are objects, their scalar fields (strings, numbers, booleans) are listed automatically; objects are expanded up to four levels, while arrays and null are not listed
- The badge on the left of each chip shows the field type:
Aatext,#number,T/Fboolean,*mixed; the number on the right is how many distinct values the field has - Hover a chip to see its path and sample values. Switch the click target between Sort and Group above the chips, then click: the sort field shows a Sort role tag and the group field shows a Group tag; click again to clear it
- With more than 8 fields a search box appears (filters by path or sample value); the first 12 are shown by default with Show all N fields / Show fewer fields
- Very wide documents are scanned up to 5,000 records and at most 150 field paths are listed; past that the tool asks you to type the full path in the input box
- The first time you pick a sort field without having chosen a strategy manually, the tool auto-selects Numeric ascending or Text ascending based on the field's numeric ratio so results appear immediately
- Before a field is picked, the right pane shows "Pick a field to sort or group" with quick-pick cards for the first 8 fields; click Sort by this or Group by this to start
- When no fields can be discovered, type a field name or path directly (see Field and path syntax below)
3. Configure grouping (optional)
- An empty Group field means sort only; fill it to bucket items by that value and the header shows "N groups"
- The input accepts field names, dot paths or JSONPath and suggests discovered paths; its tooltip reads "Bucket items by this field (leave empty to sort only). Supports field names, dot paths, or JSONPath"
- Once a group field is set, two settings appear:
- Output shape: Flat array / Grouped object
- Group order: First appearance / Group name A→Z / Group name Z→A / Largest group first
- Records missing the group field (or holding null / an empty string) go into the "Ungrouped" bucket, with a count shown below
- Invalid path syntax shows "Invalid path syntax — check brackets or quotes" and grouping is not applied
4. Configure sorting
- The sort field input accepts field names, dot paths or JSONPath; once a group field is set, its title and label become Within-group sort field
- Sort strategy has three choices: Numeric / Text / Custom (labelled Within-group sort when grouping)
- Numeric and text strategies then need a direction: Low to high / High to low for numeric, A → Z / Z → A for text
- Custom strategy opens the Custom order editor:
- In List mode drag rows to reorder, or use the up / down / remove buttons; type a value below and press Enter or click Add
- Fill field values appends every distinct value of the sort field in first-appearance order
- Values not yet in the list are shown below (up to 24); click one to append it
- Switch to Text mode to edit one value per line; it stays in sync with the list
- Unlisted values stay at the end in their original order; an empty list preserves the original order entirely
- Expand Advanced settings:
- Missing values: Nulls last (default) / Nulls first — applies to numeric and text sorting
- JSON indentation: 2 spaces (default) / 4 spaces / Compact
- Case-sensitive text sort: off by default; when on,
Aandacompare differently - A Reset defaults button appears after any change
5. Review, copy and export
- Results recalculate live; the header badge shows the item count, or "N groups · N items" when grouping
- When a sort field is set and missing values exist, a "N missing" badge is added
- The JSON view shows the complete output in a read-only box with character and line counts at the bottom
- The Preview view lists the reordered rows; when grouping, each bucket gets a card (group name + count + table) with columns for
#, Origin, the highlighted sort field (when one is set) and up to four other fields - When grouping, the JSON view also shows a row of group pills (up to 12) above the output; click one to jump to the preview
- Copy copies the full output, Copy node strips the outer
{}/[], and Export savesjson_sort_classify.json - The preview shows at most the first 300 rows (300 across buckets when grouping); Copy and Export always include everything
Sort strategies and group output
Numeric sorting
- Orders by the numeric value of the sort field;
,,$,¥,€,£and spaces are stripped before parsing, so$1,234.50and¥ 99are recognized 0is a valid value; missing, empty or unparseable values count as missing and go last by default (flip to first in Advanced settings)- Ascending and descending both preserve the relative order of missing values
Text sorting
- Natural sorting:
item-2comes beforeitem-10, not character-by-character - Case-insensitive by default; enable Case-sensitive text sort for a case-sensitive comparison
- Missing, null and empty strings count as missing and follow the Missing values setting
Custom order
- The list order is the desired order; values match exactly after trimming, case-sensitively, and the number
3is the same as the string"3" - Unlisted values go to the end in their original relative order
- An empty Custom order list preserves the original order (the usual "group only, keep in-group order" setup)
Grouping and group output
- Records are bucketed by Group field first, then the same sort strategy and sort field run inside every bucket; an empty sort field keeps the in-bucket order
- Flat array: all buckets are concatenated in group order into one array that replaces the target array
- Grouped object: emits an object keyed by group name whose values are the in-group arrays, also replacing the target array
- Group order: First appearance follows the first record of each bucket; group name A→Z / Z→A uses the same natural collation as text sorting; Largest group first sorts by bucket size and breaks ties by first appearance
- Records missing the group field go into "Ungrouped"; with group-name ascending / descending or largest-group-first ordering it is pinned last, while first-appearance ordering keeps the position of its first record
- A wrapper object (for example
{ "products": [...] }) is preserved; only the target array is replaced
Field and path syntax
- Sort and group fields are evaluated per record; write the path relative to the record and do not include the target array itself
- When a literal key contains dots, the literal key is tried first and the dot path second
- Inputs autocomplete the field paths discovered in the current JSON
Result views: JSON and Preview
- JSON: the complete output in a read-only text area with character and line counts, ready to copy
- Preview: a table of the reordered result; when grouping, each bucket gets its own card with the group name and count in the header
- Columns are
#(new index), Origin (original index with an↑/↓delta), the highlighted sort field (when one is set), and up to four other fields chosen by frequency - When the preview is truncated the footer reads "Preview shows the first 300 of N items. Copy or export for the full output."
Things to know
- Live results: there is no Start button — any input or option change recalculates immediately, and Copy / Export always take the current complete output
- Field sorting applies to object elements: non-object elements (numbers, strings, null) stay in the array untouched, but field discovery and field-based sorting do not apply to them; if the array has no objects, convert it to an array of objects first
- Missing-value placement only affects numeric / text sorting: unlisted values in custom order always go last
- Number precision: JSON numbers are parsed as floating point, so integers beyond the safe range (snowflake IDs, for example) may lose precision while parsing and in the output; the tool warns you. Store such IDs as strings when exactness matters
- Remembered settings: sort strategy, group output shape, group order, missing-value placement, case sensitivity and indentation are saved in your browser; the target array, field names and custom order are not kept after a page reload
- Everything runs locally in your browser — input never leaves your machine
Pairing with other JSON tools
- To slim a complex JSON down to a few fields before sorting: JSON Field Value Extractor
- To batch prefix/suffix, find-replace or overwrite values after sorting: JSON Node Bulk Edit
- To swap two field values: JSON Value Swapper
- To translate i18n JSON into multiple languages: JSON Translate

