N8N: Remove JSON Key in Output

I’m attempting to eliminate the JSON key from my output file in N8N. What is the most effective way to achieve this? I’m unsure how to get it done. I want to return the complete array of data with all its values, rather than just a single value.

Currently, my output looks like this:

{
  "data": [
    {
      "id": 21428
    }
  ]
}

And I need to remove the key “data” to achieve this output:

[
  {
    "id": 21428
  }
]

I’ve tried altering my item list to split the output, but it hasn’t worked. Any suggestions on how to accomplish this?

Just use a Code node with a simple JavaScript expression to grab the array part. Access your input data and return only the array: return items[0].json.data; This strips the wrapper object and gives you the raw array you want. Don’t forget to set the Code node to return multiple items if your array has more than one element. I’ve done this tons of times with APIs that wrap responses in pointless containers - works every time without any complex stuff.

The Set node works great here. Just set it to “Keep Only Set Fields” mode and create a new field that points directly to your array. Name it something like “result” and use {{$json.data}} as the value. This pulls out just the array without that wrapper key. I prefer this over code nodes since it’s built into N8N and handles everything natively. Don’t forget to enable “Keep Only Set Fields” or you’ll end up with both the old structure and your new field.

use a function node instead - just add return $input.all()[0].json.data and it’ll strip out that wrapper automatically. way simpler than messing with set nodes. just make sure your function returns the array directly.