How to extract array from JSON wrapper object in N8N workflow

I need help with extracting just the array contents from a JSON response that’s wrapped in an object. My workflow returns data inside a parent key, but I want to remove that wrapper and only get the inner array.

Current JSON structure:

{
  "items": [
    {
      "user_id": 15673
    }
  ]
}

Target structure:

[
  {
    "user_id": 15673
  }
]

I’ve attempted using the split output option in my item list settings, but it didn’t work as expected. What is the correct method to unwrap this JSON object and return just the array value? I need it to support multiple items in the array, not just single values.

try using the code node with return items[0].json.items.map(item => ({json: item})) - it extracts the array and reformats it for n8n. worked for me when I had the same wrapped API issue.

The Function node works great for this. Use return [{json: $input.first().json.items}] to pass the whole array as one item, or return $input.first().json.items.map(item => ({json: item})) to split each array element into separate n8n items. I’ve had better luck with Function nodes than Code nodes for simple stuff like this - they handle n8n’s item format automatically. Just double-check your input structure first so you don’t get errors when the API response changes.

You can also use the Set node with ‘Keep Only Set’ enabled. Just grab the value from the items field and map it straight to your output. Name the field something like data and use {{$json.items}} to pull out the array contents. It’s cleaner than code nodes for simple unwrapping and keeps the item structure n8n expects. Really handy when APIs always wrap their responses in metadata objects.