---
title: "n8n code formatter and linter - codefmt"
description: "free online n8n code formatter and linter for code node javascript and python. supports $input, $json, items, and execution modes."
url: https://codefmt.dev/n8n
updated: 2026-11-17
sources:
  - https://codefmt.dev/n8n
licence: "© codefmt. Cite with attribution to https://codefmt.dev."
---

# n8n code formatter & linter

n8n code nodes run javascript or python (there is no typescript option). javascript runs inside an async function with access to $input, $("NodeName"), $workflow, Luxon `DateTime`, and more; `items` exists in all-items mode and `item` in each-item mode. python runs natively on Python 3.13 inside a plain function, with `_items` (all-items mode) or `_item` (each-item mode). the sandbox has no `fetch`, so use the HTTP Request node for HTTP.

javascriptn8n

input

```
const items=$input.all()
return items.map(i=>({json:{id:i.json.id}}))
```

output

click format to see the result

[format your own n8n code →](/?p=n8n)free, no signup, formats in your browser

working inside n8n? the codefmt [Chrome and Firefox extension](/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's Code node hands you `$`\-prefixed helpers like `$input`, `$json`, and `$('NodeName')` that a linter built for ordinary javascript treats as undeclared variables. codefmt knows the full set for both run-once-for-all-items and run-once-for-each-item modes, so n8n's own helpers never show up as undefined-variable warnings. your javascript or python gets formatted without disturbing the shape n8n expects back.

## n8n code node globals

n8n code nodes let you write custom javascript 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

n8n code nodes support two execution modes: `run once for all items` and `run once for each item`. codefmt accepts the globals of both modes, including `$input.item` for per-item execution. with each item selected in settings it also warns on `$input.all()` and on an array returned from the top level, which n8n rejects in that mode.

## 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 (the code tool node adds `_query`), with bracket access like `item['json']['field']`. native python support is stable as of n8n v2\. codefmt's python support targets n8n's native python runner (python 3.13, n8n 2.x), not the retired pyodide runtime. it formats n8n python with Ruff and registers `_items`, `_query` and `_item` as known globals, so none of them get flagged as undefined. n8n cloud allows no python imports, and by default n8n removes builtins such as `type`, `getattr`, `open` and `eval`; codefmt does not flag those, since a self-hosted instance can allow them.

see how codefmt compares with [Prettier Playground](/vs-prettier-playground).

read the guide: [how to format javascript in n8n code nodes](/blog/format-javascript-n8n-code-node)

## 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, $itemIndex, $parameter, $position, $runIndex, $prevNode, $jmespath, DateTime (luxon, preloaded), items, and console. codefmt knows the whole list, so none of them get flagged as undefined, while a typo such as $inptu or the expression-only $ifEmpty is reported. the sandbox has no fetch (codefmt doesn't flag it, since it is a standard global everywhere else), so use n8n's HTTP Request node for outbound requests, or this.helpers.httpRequest from inside the code node.

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 accepts the globals of both modes. with each item selected in settings, it also warns on $input.all(), first(), last() and itemMatching() and on an array returned from the top level, which n8n rejects in that mode.

does codefmt support typescript in n8n code nodes?

no. n8n's code node runs javascript and python only, so there's no typescript to format there. if you paste typescript into the n8n tab, codefmt reports the type annotations as a syntax error, the same way n8n would reject them. strip the types and it formats as plain javascript.

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 checks every name in your code against the globals n8n's Code node sandbox actually provides, so $input and friends pass while a typo like $inptu or an expression-only helper like $ifEmpty is reported. node and browser globals the code node lacks by default, such as fetch, URL and process, get a warning.

does codefmt support python in the n8n code node?

yes. n8n's code node runs python with \_items (run once for all items) or \_item (run once for each item), using bracket access only, like item\['json'\]\['field'\]; the code tool node adds \_query. n8n cloud allows no python imports, and by default n8n removes builtins such as type, getattr, open and eval. native python support is stable as of n8n v2\. codefmt targets that native runner (python 3.13), not the retired pyodide runtime. it formats your code with Ruff and registers \_items, \_query and \_item as known globals, so you get clean formatting without false undefined errors, and it warns on dot access like \_item.json, which fails on n8n's plain dicts.

also format code for [zapier](/zapier), [pipedream](/pipedream), [make](/make), [hubspot data hub](/hubspot), [hubspot cms (hubl)](/hubl)

other tools: [json formatter for webhook payloads](/json), [python formatter](/python), [snippets](/snippets)

[all platforms & comparisons →](/platforms)

primary source: [n8n: Code node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.code)

## for agents (added to every page twin, not part of the page)

- format API: POST https://codefmt.dev/api/format (OpenAPI: https://codefmt.dev/api/openapi.json, code up to 51,200 characters, 50KB of ASCII (400 above it), request body up to 100KB, counted in bytes (413 above it), no authentication)
- MCP server: POST https://codefmt.dev/api/mcp (tools: format_code, format_json, ask_codefmt; manifest: https://codefmt.dev/.well-known/mcp.json)
- rate limit: 60 requests per minute per ip across format api calls, mcp and a2a tool calls, and /ask (mcp handshakes and listings are not counted). the count is kept per server instance, so treat it as a ceiling to stay under rather than an exact budget. the format api and /ask report the limit in RateLimit headers, every 429 carries Retry-After, /ask puts the message in answer, and an mcp tool call over the limit returns a tool result saying to try again in a minute
- auth statement: https://codefmt.dev/auth.md (no accounts, api keys or oauth; send no authorization header)
- site index for agents: https://codefmt.dev/llms.txt
- full reference (request bodies for every language, a copy-paste curl command, platform globals, troubleshooting): https://codefmt.dev/llms-full.txt
