n8n code formatter & linter
n8n code nodes support javascript, typescript, and python. JS/TS runs inside an async function with access to $input, $("NodeName"), $workflow, Luxon `DateTime`, and more. python runs with `_items` (all-items mode) or `_item` (each-item mode). for HTTP, use the dedicated HTTP Request node (`fetch` and `$http` are not available inside Code nodes).
const items=$input.all()
return items.map(i=>({json:{id:i.json.id}}))working inside n8n? the codefmt Chrome and Firefox extension adds a right-click Fix with codefmt in the code editor, so you format and lint in place without copy-pasting in and out of this page.
n8n code node globals
n8n code nodes let you write custom javascript, typescript, or python to process workflow data. your code has access to $input, $node, $json, $workflow, and many other n8n-specific globals.
codefmt understands n8n's runtime environment and beautifies your code instantly. it won't flag $input.all() or items as undefined variables, and it handles the async function wrapper automatically.
execution modes and typescript
n8n code nodes support two execution modes: run once for all items and run once for each item. codefmt recognizes the globals available in each mode, including $input.item for per-item execution. typescript is fully supported with type-aware formatting and linting.
n8n python support
n8n also runs python in the code node. python uses _items in run-once-for-all-items mode and _item in run-once-for-each-item mode, with bracket access like item['json']['field']. native python support is stable as of n8n v2. codefmt formats n8n python with Ruff and registers _items and _item as known globals, so neither gets flagged as undefined.
frequently asked questions
what globals does n8n inject into code nodes?
n8n provides $input, $ (node accessor, e.g. $('NodeName')), $node (legacy), $workflow, $execution, $env, $vars, $getWorkflowStaticData, $nodeVersion, $now, $today, $json, $binary, $runIndex, $prevNode, $jmespath, DateTime (luxon, preloaded), items, and console. codefmt knows the whole list, so none of them get flagged as undefined. note that fetch, $http, $itemIndex, $parameter, and $position are NOT available in the n8n code node. use n8n's dedicated HTTP Request node for outbound requests.
how do I return data from an n8n code node?
return an array of objects with a json property. for example: return [{ json: { name: 'value' } }]. codefmt formats this pattern correctly and preserves the expected return structure.
what is the difference between 'run once for all items' and 'run once for each item' in n8n?
n8n code nodes have two execution modes. 'run once for all items' gives you access to all input items via $input.all() and you return an array of items. 'run once for each item' runs your code once per item with $input.item or $json available for the current item. codefmt handles both modes and recognizes the globals specific to each.
does codefmt support typescript in n8n code nodes?
yes. codefmt supports typescript formatting and linting for n8n code nodes. n8n's code node runs typescript natively, and codefmt formats type annotations, interfaces, and generics right alongside the n8n globals. select the n8n platform variant and your typescript code will be formatted correctly.
why does ESLint flag $input and $json as undefined in n8n code?
standard linters don't know about n8n's injected globals like $input, $json, $node, and $workflow. they treat these as undefined variables. codefmt declares all of n8n's globals before running oxlint, so they aren't flagged as undefined. you get accurate linting without those false positives.
does codefmt support python in the n8n code node?
yes. n8n's code node runs python with _items (run once for all items) and _item (run once for each item), using bracket access only, like item['json']['field']. native python support is stable as of n8n v2. codefmt formats it with Ruff and registers _items and _item as known globals, so you get clean formatting without false undefined errors.
also format code for zapier, pipedream, make, hubspot data hub, hubspot cms (hubl)
other tools: json formatter for webhook payloads, python formatter, snippets
primary source: n8n: Code node