n8n Remove JSON Key From Output: Return a Bare Array
To n8n remove json key from output, use a Split Out node on the field holding the array (for example data), then return the items with Respond to Webhook set to All Incoming Items. This gives [{"id":1},{"id":2}].
- Every n8n item is {json: {...}}, so the 'data' key is a normal field inside json and the item wrapper is always present in the editor.
- Split Out with Fields to Split Out = data turns one item holding an array into one item per element.
- Respond to Webhook with Respond With = All Incoming Items returns a bare array of each item's json, with no wrapper.
- An Aggregate node set to All Item Data is the usual source of an unwanted data key, so remove it or rename its output field.
- Verify the real response with curl, because the editor output panel always shows items.
Why does n8n wrap my output in json and a data key?
Every n8n node passes an array of items, and each item is an object shaped like {json: {...}, binary: {...}}. The Table, JSON and Schema views show the contents of json, so you never see a truly keyless item. You cannot make n8n output an item without the wrapper. You can only choose what the final response body, file or HTTP request body contains.
The data key you see is a field inside json. It usually comes from an Aggregate node (All Item Data), an HTTP Request node that received an API response like {"data": [...]}, or an AI or Code node that returned it. Fixing the problem means turning one item holding an array into many items, then sending those items out in a format that drops the wrapper.
How do I diagnose whether the array is nested or already split?
Open the node just before your output and switch between views. The item count at the top of the panel is the quickest signal.
- Look at the item count. 1 item means the array is inside a field. N items means it is already split.
- Switch to JSON view. If you see [{"data": [ ... ]}], the array sits in one item's data field.
- Check the field type in Schema view. An array shows as a list icon, while a string containing brackets means the JSON was never parsed.
- Note the full path. If you see data.results, the array is nested one level deeper.
- If you have many items each with their own fields, you do not need to split anything, only to return them correctly.
Which method fits my situation?
Match the symptom to the fix before changing nodes. Most failures come from using the right node on the wrong shape.
| Situation | Fix | Key setting |
|---|---|---|
| 1 item with data: [..] | Split Out node | Fields to Split Out = data; Include = No Other Fields |
| Array nested deeper | Split Out with dot notation | data.results |
| data is a JSON string | Parse first, then Split Out | Edit Fields type Object, or Code with JSON.parse |
| Aggregate node created the wrapper | Remove Aggregate or rename its field | Put Output Field name to something else, or delete the node |
| Need a guaranteed array in the response | Respond to Webhook in JSON mode | {{ $json.data }} |
| Single item must return one object | First Incoming Item | Respond With = First Incoming Item |
How do I unwrap the array with Split Out?
Split Out is the standard method. It reads an array field from one item and creates one item per element.
Using the example input, the node receives one item and outputs two.
- Add a Split Out node after the node that produces {"data": [...]}.
- Set Fields to Split Out to data.
- Under Include, choose No Other Fields so sibling fields are not copied onto each element.
- For nested arrays write the path with dot notation, such as data.results.
- Run the node and confirm the item count equals the number of elements.
// Before (1 item)
[{"data":[{"id":1},{"id":2}]}]
// After Split Out (2 items, shown in the editor as json fields)
[{"id":1},{"id":2}]How do I return a raw array from Respond to Webhook?
On the Webhook node, set Respond to Using 'Respond to Webhook' Node. Without it the workflow replies immediately with its default message and your Respond node is never used.
Then configure Respond to Webhook with one of these options. Each one gives a different body shape.
| Respond With | Response body | Use when |
|---|---|---|
| All Incoming Items | [{"id":1},{"id":2}] | You want an array of every item's json after Split Out |
| First Incoming Item | {"id":1} | You want a single object |
| JSON | Whatever your expression returns | You need a guaranteed array shape |
Respond With: JSON
Response Body: {{ $json.data }}
// If the data is already split into items and you need one array:
{{ $input.all().map(i => i.json) }}What about Edit Fields, Code, Aggregate and files?
Edit Fields (Set) can map {{ $json.data }} into a field, but that only creates a property. The result is still {json: {data: [...]}}, so it does not remove the wrapper by itself. Turn off Include Other Input Fields to keep only the field you set, and follow it with Split Out or a JSON response body. Use the Object type if the value arrives as a string.
In a Code node set to Run Once for All Items, you must return items shaped as {json: ...}. Returning raw objects triggers the error "Code doesn't return items properly".
Aggregate is the reverse operation. With All Item Data it puts items into a data field, which is the usual cause of the unwanted key. Delete it or choose a different output field name if you do not need the grouping.
Files need care because data can also be a binary property name, which is not a JSON key. In the Binary tab the property is listed separately from the JSON view. The Convert to File node's JSON operation has a Mode option that either puts all items into one file or writes each item to its own file, so choose the mode that matches the file you need and check the result by opening the file. The Item Lists node is deprecated in favour of Split Out and Aggregate, so use those nodes in new workflows.
// Nested array in one item -> many items
return $input.first().json.data.map(x => ({ json: x }));
// Already flat items: return them as they are
return $input.all();
// data is a JSON string
const arr = JSON.parse($input.first().json.data);
return arr.map(x => ({ json: x }));
// Wrong: raw objects, causes "Code doesn't return items properly"
// return [{ id: 1 }, { id: 2 }]; How do I verify the real response and avoid common mistakes?
The editor output panel always shows items, so it cannot prove what your endpoint returns. Call the production or test URL instead.
Test the real response from a terminal.
- Activate the workflow, or use the test URL while listening for a test event.
- Run the curl command below and read the body.
- Compare it with the expected array and check the Content-Type header.
curl -i -X POST https://your-n8n-host/webhook/your-path \
-H 'Content-Type: application/json' \
-d '{"test":true}'Common questions
Can n8n return an array without the data key from a Code node?
Yes, but the Code node still returns items. Return {json: x} objects, then let Respond to Webhook with All Incoming Items send the bare array. Alternatively, use Respond With JSON and an expression to output the array directly.
Why does Split Out return nothing?
The field name is usually wrong, the field is a string and not an array, or the array sits deeper than the path you typed. Check the field in Schema view and use dot notation for nested paths.
Does Edit Fields remove the json wrapper?
No. Edit Fields only changes the fields inside json, so the item still has the wrapper. It is useful for renaming or keeping only certain fields before Split Out or a response.
How do I flatten nested JSON in n8n?
Use Split Out with dot notation for nested arrays, then Edit Fields to rename or move properties. For deeply irregular data, a Code node with map or flatMap gives full control.
Why does my webhook return an object instead of an array?
When the workflow ends with a single item, All Incoming Items can return one object. Use Respond With JSON and an expression that returns an array, such as {{ $input.all().map(i => i.json) }}.