Restructure (Free Online Tool)

Flexibly restructure collections by grouping, unwinding, transposing, or rearranging nested data

Paste your JSON → Get results instantly (no signup)

⚡ Instant resultsNo signupRuns in your browser
Try examples:

Group these items by their type.

[
{
"type": "fruit",
"name": "Apple"
},
{
"type": "vegetable",
"name": "Carrot"
},
{
"type": "fruit",
"name": "Banana"
}
]
Output
1{
2 "fruit": [
3 {
4 "name": "Apple"
5 },
6 {
7 "name": "Banana"
8 }
9 ],
10 "vegetable": [
11 {
12 "name": "Carrot"
13 }
14 ]
15}

Love the result?

Use this exact pipeline in your app, backend, or LLM workflow.

No setup needed. Works with curl, Node, Python.

Uses example data. For edited input, copy from the playground.

Read integration guide

Works with:

  • API responses
  • Nested JSON
  • Arrays & objects

Example: input → output

Input / Output
Input
[
{
"type": "fruit",
"name": "Apple"
},
{
"type": "vegetable",
"name": "Carrot"
},
{
"type": "fruit",
"name": "Banana"
}
]
Output
{
"fruit": [
{
"name": "Apple"
},
{
"name": "Banana"
}
],
"vegetable": [
{
"name": "Carrot"
}
]
}

Related tools

Advanced usage (optional)

Restructure

v1.0.0
Structure
objectarraydestructive

Description

Restructure

Reshape JSON structure — group items by a key, sort items or keys, unwind array fields into separate records, or transpose rows and columns.

Modes

Group By

Group array items by a specified field value. Creates an object where each key is a unique value of the group-by field, and the value is an array of matching items (with the group-by field removed).

[{ "type": "fruit", "name": "Apple" }, { "type": "fruit", "name": "Banana" }]
→ { "fruit": [{ "name": "Apple" }, { "name": "Banana" }] }

Sort

Sort array items by a field value, or sort object keys alphabetically. Supports ascending and descending order.

Unwind

Expand array fields into separate records. Each item in the array field becomes its own record with all other fields duplicated.

[{ "name": "Alice", "tags": ["admin", "editor"] }]
→ [{ "name": "Alice", "tags": "admin" }, { "name": "Alice", "tags": "editor" }]

Transpose

Swap rows and columns. Convert an array of objects into a column-oriented structure, or vice versa.

Configuration

FieldTypeDefaultDescription
Modeenumsortgroup-by, sort, unwind, or transpose
Group By Keystring""Field name to group by (group-by mode)
Sort By Keystring""Field name to sort by (empty = sort primitives or object keys)
Sort Orderenumascasc or desc
Unwind Fieldstring""Field containing arrays to unwind (unwind mode)
Target Pathspath-picker[]Scope operation to specific paths (empty = apply to root)

Use Cases

Data Organization

  • Categorize: Group products by category, users by role, events by type
  • Sort records: Sort by date, name, score, or any other field
  • Alphabetize keys: Sort object keys for consistent ordering

Data Transformation

  • Denormalize: Unwind tag arrays to create one record per tag for analysis
  • Pivot tables: Transpose row-oriented data to column-oriented format
  • Aggregation prep: Group records before applying aggregate operations

Reporting

  • Category reports: Group sales by region, expenses by department
  • Ranked lists: Sort results by score, revenue, or date
  • Flat exports: Unwind nested arrays for CSV export

Configuration

NameTypeDefaultDescription
Modeenumsortgroup-by: group array items by a field. sort: sort items or keys. unwind: expand array fields. transpose: swap rows and columns. group-by sort unwind transpose
Group By KeystringField name to group by (used in group-by mode)
Sort By KeystringField name to sort by for arrays of objects (empty = sort primitives or object keys)
Sort OrderenumascSort direction (used in sort mode) asc desc
Unwind FieldstringField name containing arrays to unwind (used in unwind mode)
Target Pathspath-picker[]Scope operation to specific paths only (empty = apply to root)

Examples

AI Prompt
Group these items by their type.
[
{
"type": "fruit",
"name": "Apple"
},
{
"type": "vegetable",
"name": "Carrot"
},
{
"type": "fruit",
"name": "Banana"
}
]
Output
1{
2 "fruit": [
3 {
4 "name": "Apple"
5 },
6 {
7 "name": "Banana"
8 }
9 ],
10 "vegetable": [
11 {
12 "name": "Carrot"
13 }
14 ]
15}
Config
Mode
group-by
Group By Key
type
Sort By Key
Sort Order
asc
Unwind Field
Target Paths
all

API Usage

POST /api/v1/utilities/structure.restructure
Example:
curl -X POST https://your-domain.com/api/v1/utilities/structure.restructure \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"inputs":{"primary":[{"type":"fruit","name":"Apple"},{"type":"vegetable","name":"Carrot"},{"type":"fruit","name":"Banana"}]},"config":{"mode":"group-by","groupByKey":"type","sortByKey":"","sortOrder":"asc","unwindField":"","targetPaths":[]}}'
Response
1{
2 "fruit": [
3 {
4 "name": "Apple"
5 },
6 {
7 "name": "Banana"
8 }
9 ],
10 "vegetable": [
11 {
12 "name": "Carrot"
13 }
14 ]
15}