n8n Code node vs expression vs Edit Fields: a three rung ladder

By Christophe Paka · Facts checked on 23 October 2026

You open a workflow a colleague built. The node says Send Email, but its To field holds a long formula. Or an AI tool wrote a Code node for a job one field could do. You cannot tell what the workflow does without reading code.

That is the real cost of the n8n Code node vs expression choice: every step up adds upkeep for the next person.

The figure below lays out the three places a mapping can live, what each one costs, and the one rule that picks between them.

Three rungs: 1, an expression in the parameter, costs nothing on the canvas; 2, a node such as Edit Fields (Set), costs one more node; 3, the Code node in JavaScript or Python, costs code to test and maintain.
Figure 4.2 Each rung adds power and adds upkeep; most mapping belongs on the first rung.

How to read this figure

  1. Read the banner first. The top line is the rule: climb only when the rung below cannot do the job. Each rung adds power, and each one adds upkeep.

  2. Rung 1: the expression. An expression is a small formula inside a field, between {{ }}, such as {{ $json.email }} for this order's email. Use it to pull a value from a previous node or do a light calculation. It costs nothing on the canvas, but it holds one short formula, not several steps. See how one expression answers per item.

  3. Rung 2: a transformation node. Edit Fields (Set) is the usual one. Use it when the job matches what the node is built for, when you want a guided screen with no code, or when the mapping should be visible on the canvas. It costs one more node to run and read.

  4. Rung 3: the Code node. The Code node runs JavaScript or Python. Use it when the logic outgrows a field, when you need the whole list of items at once, or when no node makes the shape you need. It costs code that someone must test and maintain.

  5. Check the Code node limits. The figure lists the Code node's limits. It runs in one of two modes: once for all items (the default) or once for each item. On n8n Cloud it cannot load ready made code packages from the web (npm), read files or call the web. For web calls, use the HTTP Request node. Python sees only the items in front of it. Whatever the language, the code must hand back a list of items.

Key takeaways

  • Put a value from an earlier node, or a small change to it, in an expression.
  • Use Edit Fields with a clear name such as Clean order when a colleague should see the mapping.
  • Move up to the Code node only for the whole list at once, or a shape no node makes.

Worked example: three mappings, three rungs

Take three jobs from one order workflow and place each one with the rule of thumb.

  1. Send each confirmation to the customer's email from the trigger: one value from an earlier node, so an expression in the To field.
  2. Rename and tidy the order fields before they go to a sheet: a mapping a colleague should see, so an Edit Fields node named Clean order.
  3. Work on the whole list at once, in a shape no node makes: the Code node.
  4. A field formula that needs a named value or several steps no longer fits on rung 1. Treat that as the sign to move up a rung.

Result: Two of the three jobs need no code at all. The next person who opens the workflow reads the mapping on the canvas, and finds the one Code node fast.

Questions readers ask

Do I need the Code node if I do not code?

Usually not. Most mapping belongs on the first two rungs: drag a field to write an expression, or use Edit Fields. In a mixed team, the office manager maps fields by dragging. A developer writes the one Code node that needs it, on the same canvas, where both can read it.

If I can code, should I just use the Code node for everything?

No. Each rung adds upkeep. A Code node is code someone must test and maintain, and a mapping hidden in it is hard for a colleague to read. Stop at the lowest rung that does the job.

Can I import npm packages in the Code node on n8n Cloud?

No. On Cloud the Code node has no npm imports (ready made code packages), no file system and no HTTP requests. For a web call, use the HTTP Request node. On your own server, extra modules can be allowed, so if your transforms need outside packages, plan for your own server.

Why is my Python Code node so limited?

Native Python in the Code node sees only _items and _item, and no other built ins. Write your Python against those two, and return an array of { json: ... } objects.

Sources: Expressions versus data nodes (n8n docs); Using the Code node (n8n docs); Edit Fields (Set) (n8n docs).

This figure is from n8n Made Crystal Clear, chapter 4.

The chapter builds the idea step by step, with recipes you can follow, a Try it to check yourself, and every source.

Get the book

All diagrams