Learn how to use expressions in n8n to automate workflows, transform data, and boost efficiency with clear examples and practical tips.

Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
In n8n, you use expressions by typing {{ ... }} inside any field that shows the “gear” icon or the “Expression” toggle. An expression lets you pull values from previous nodes (like {{$json.email}}), combine them, or run small pieces of JavaScript. Expressions always run at execution time, not when you type them, and they read whatever data the previous node outputs. In practice, you use expressions whenever a value shouldn’t be hard‑coded — things like dynamic emails, IDs, URLs, or timestamps.
An n8n expression is just a short piece of JavaScript wrapped in {{ }} that lives inside a field. When the workflow runs, n8n evaluates that JavaScript against the current item’s data. “Item” means the JSON object flowing from node to node.
Inside an expression, you can use:
Date(), String(), string methods, etc.
The most common expression is pulling something from a previous node, usually the node right before:
{{$json.email}}
This means: “in this item, look inside the JSON, and return the value called email.”
If that field was nested, you just go deeper:
{{$json.user.profile.lastName}}
If you need the output of a specific node:
{{$prevNode["Get User"].json.id}}
You can type {{ }} in the field, or click the small “Expression” toggle. When enabled, the field becomes dynamic and n8n highlights it in purple.
Tip: If the expression is invalid, n8n will highlight an error right in the field. It won’t break your whole workflow — it just won’t evaluate during execution.
Building a dynamic name (after an API returns first and last name):
{{$json.firstName + " " + $json.lastName}}
Compose a dynamic Slack message:
{{"New user signed up: " + $json.email + " at " + new Date().toISOString()}}
Read an environment variable (great for API URLs or secrets):
{{$env.BASE_URL + "/api/v2/users"}}
Create a fallback when a field might be missing:
{{$json.username || "unknown-user"}}
Every node runs per item. That means:
$json always refers to the item currently being processed.So if you want to transform data, you usually use a Code node or Set node, not just an expression field.
One good test is to switch the field to expression mode and click the “value preview” icon (the little eye). n8n shows the actual value based on the last workflow run.
Use an expression when the logic is short and tied to a specific field. Use a Code node when the logic grows beyond a few lines or you need loops, conditionals, or multi-field transformations. Expression fields should remain readable — that’s the real production rule.
In production, expressions are best for:
Anything heavy or anything that changes often should live in a Code node or a database, not inside long expressions. That keeps your workflow maintainable and error‑resistant.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.