Most likely the code only reads one item. In “Run Once for All Items” mode, $input.first() or items[0] picks up just the first item, and returning a single object gives you one output item. Loop over all of them and return an array:
The other option is to set Mode to “Run Once for Each Item”, use $input.item.json, and return one object. n8n then runs the code once per item.
Check the previous node’s output too. If it says “1 item” and the results sit in an array inside it (common with HTTP Request, for example in a data field), there is only one item to start with. Split it with a Split Out node on that field, or in the Code node:
return $input.first().json.data.map(d => ({ json: d }));
If neither of these fits, paste your Code node’s code and the item count shown on the previous node’s output.
If the Code node is set to Run Once for All Items, use $input.all() to access every incoming item. Then process them with .map() and return the resulting array. Returning a single object will cause n8n to produce only one output item.
That is the classic first-item-only mode. Your Code node is set to Run Once for First Item, so it executes with only items[0]. The fix:
Open the Code node and set Mode to Run Once for All Items. Then $input.all() contains everything, and your return should be the full array:
return $input.all();
If you are transforming per item, iterate explicitly and build the output array yourself - never rely on the node auto-looping in first-item mode, it will not.
Quick mental model: Run Once for All Items = the node runs ONE time with the full array (good for aggregations and API paging). Run Once for Each Item = runs N times (good for per-item transforms). First Item is almost never what you want. Hope that unblocks you - and if you keep hitting these n8n snags while building client workflows, this is literally my day job, happy to help at some point.