FlowKit

n8n's AI Transform node: transforming your data with a prompt instead of code

Published 15 August 2026 · 6 min read

Reformatting an API's JSON response, flattening a nested array, renaming a handful of fields before sending them to Google Sheets: these are tiny needs that come up in almost every n8n workflow, and yet they force you to open a Code node and write a few lines of JavaScript. The AI Transform node, available on n8n Cloud plans, offers another path: describe the transformation in one sentence and let a language model write the code for you. Here's what it actually does, where it stops, and how to reproduce the same convenience if you're self-hosted.

What the AI Transform node is

AI Transform is a native n8n node that generates a code snippet from a natural-language prompt. Unlike the AI Agent or a Basic LLM Chain, it doesn't fit into a conversational pipeline: it serves a single, one-off purpose — transforming data flowing through the workflow — and does it in one interaction, at build time, not at runtime.

What sets it apart from a plain copy-paste from ChatGPT is that it's context-aware. The node reads the schema of the data produced by preceding nodes (field names, types) and uses it to generate code that's consistent with your actual workflow, without you having to paste an example payload into the prompt.

How it actually works

Using it comes down to three steps:

  1. Add the AI Transform node right after the node whose output you want to transform.
  2. Describe the transformation you want in a prompt field capped at 500 characters — enough for a precise instruction ("extract the email and name from each contact, uppercase the name, skip entries without an email"), not enough for a full specification.
  3. Click Generate code. The node displays the generated code and runs it directly against the input data, with a preview of the result.

The generated code stays read-only inside the node: you can't fix a stray comma by hand. Two paths if the result isn't exactly right: rephrase the prompt and regenerate, or copy the code into a regular Code node to adjust it line by line — worth knowing before you build an entire workflow around the AI Transform node, in case a manual fix turns out to be needed later.

What it does well

The AI Transform node targets a specific job: data structure transformations, not complex business logic. A few representative examples:

  • Flattening a nested object — pulling data.customer.address.city into a flat city field from a deeply nested API response;
  • Renaming and filtering fields — turning a CRM export in English (first_name, last_name, email_address) into field names consistent with the rest of the workflow;
  • Recomposing an array — turning an array of objects [{sku, qty}, ...] into a readable summary string for a Slack message or an email;
  • Cleaning before writing — dropping empty or duplicate fields before an insert into Google Sheets or Airtable.

In every case, the transformation stays self-contained: it starts from data already at the input and produces an output, with no external call and no judgment call involved (in which case a Text Classifier, Information Extractor, or Structured Output Parser node — see our guides on the Text Classifier and the Information Extractor — remain the better fit).

Its limits, stated plainly

Three limits shape how you can actually use it:

  • Cloud-only. The node doesn't show up on a self-hosted instance, regardless of the version installed — see the workaround below.
  • No network access. The AI only works with data already present in the workflow; it can neither query an API nor enrich a value from an external source. For that, an upstream HTTP Request node is still required.
  • It knows the schema, not the values. The model sees field names and their types, not the actual content of your data. A prompt that assumes a particular value ("if the status is 'urgent'") works better when you spell out the exact expected value rather than let the model guess the vocabulary used in your data.

On workflows with many upstream nodes, the quality of the generated code can also degrade — the context passed to the model gets harder to interpret with a long, heterogeneous node history. In that case, a Set or Edit Fields node right before AI Transform, exposing only the relevant fields, noticeably improves the reliability of the result — the same instinct covered in our guide on the Set and Edit Fields node.

AI Transform, the Code node, and the Code node's AI assistant: which one to use

n8n actually offers two AI entry points for writing code, both Cloud-only:

AI Transform Code node's AI assistant
Location Dedicated node Button inside an existing Code node
Generated code Read-only in the node Directly editable
Use case Quick, one-off transformation Help or fixes on a Code node already in place
Self-hosted No No

For anything beyond a structural transformation — complex conditional logic, npm module calls, nested loops — a Code node written or fixed by hand (with or without AI help) remains the more reliable tool. Our guide on JavaScript expressions in the Code node covers that path in detail, as does our article on the Code node in Python for the Python alternative, which AI Transform doesn't cover.

Self-hosted? Reproduce the same convenience

Not having the node on a self-hosted instance isn't a dead end — it just moves the AI step outside n8n. The principle: ask a language model for the transformation once, outside the workflow, then paste the result into a regular Code node, which works everywhere.

Two ways to do it:

  • As a one-off, by pasting an example JSON payload and your requirement into Claude's or ChatGPT's web interface, then copying the generated JavaScript into a Code node — the manual equivalent of the "Generate code" button, without the 500-character cap or the read-only restriction.
  • Inside the workflow itself, with an AI Agent node or a Basic LLM Chain connected to your own OpenAI or Anthropic credential — see our guide on connecting Claude or GPT to n8n — which generates the code on demand and passes it to a downstream Code node via an expression. More work to build than AI Transform, but fully portable, with no dependency on a particular Cloud plan. Our self-hosted vs Cloud comparison covers this kind of feature trade-off more broadly, and our Cloud pricing guide details which plans include AI Transform.

Always review what the AI wrote

Saving time writing code doesn't excuse skipping the review. A 2023 study by Peng, Kalliamvakou, Cihon and Demirer, run on developers using GitHub Copilot to implement an HTTP server, found a striking speed gain — developers with the AI assistant completed the task 55.8% faster than the control group (Peng et al., 2023). That same speed gap applies to the AI Transform node: the question isn't whether the AI writes code faster than you would, it's whether the code it wrote does exactly what you wanted. On a misspelled field or an inverted condition, the node's output preview — always visible before you activate the workflow — remains the fastest and most reliable check.

Wrapping up

n8n's AI Transform node generates JavaScript from a prompt capped at 500 characters, relying on the schema of data already present in the workflow — useful for reformatting, flattening, or cleaning data, not for complex logic or external calls. Cloud-only, it can be reproduced manually on self-hosted instances via a one-off LLM call followed by a paste into a regular Code node. This same AI-assisted code generation pattern, portable to any n8n instance, is exactly what powers the workflows in the AI Inbox Pack (€79) — LLM chains, structured output, and data transformation, ready to use and editable without depending on a particular Cloud plan.

FAQ

Frequently asked questions

Does the AI Transform node work on self-hosted n8n?

No. As of now, the AI Transform node — like the Code node's AI assistant — is only available on n8n Cloud plans. A self-hosted instance won't show it in the nodes panel. The workaround is to generate the code once through an external LLM (Claude, GPT) and paste it into a regular Code node, which works everywhere.

What language does the AI Transform node produce?

JavaScript, running in the same execution environment as n8n's standard Code node (access to $input, $json, the same global objects). There's no option to generate Python with this node.

Can you edit the generated code directly inside the node?

No, the code shown inside the AI Transform node is read-only. To adjust it, you have two options: rephrase the prompt and regenerate, or copy the generated code into a separate Code node where it becomes freely editable.

Can the node fetch data that isn't already in the workflow?

No. The AI only works with the data already present at the node's input — it makes no network calls and can't query a third-party API. To enrich data from an external source, you need an HTTP Request node or a dedicated integration node upstream.

Bundle FlowKit Complet

€269