Affiliate/Ads disclaimer: Some links on this blog are affiliate/ads links to support this project going on, meaning I may earn a commission at no extra cost to you.
n8n Expressions: Variables, Functions & JMESPath Reference
n8n expressions are dynamic, runtime‑evaluated snippets enclosed in
{{ double curly braces }} that access data from any node,
workflow metadata, environment variables, or built‑in functions. They
resolve on every execution, pulling the latest values from $json,
$node, or $jmespath() without hardcoding fields. This
guide covers the core variables, Luxon DateTime library, JMESPath querying,
and advanced patterns like $if() and $vars for
reusable automations.
[1]
| Variable / Function | Description | Example |
|---|---|---|
{{ $json.field }} |
Access field from current item | {{ $json.email }} |
{{ $node["NodeName"].data }} |
Reference another node’s output | {{ $node["HTTP Request"].json.id }} |
{{ $now }} |
Current date/time (Luxon) | {{ $now.toISO() }} |
{{ $jmespath($json, "path") }} |
JMESPath JSON query | {{ $jmespath($json, "people[*].name") }} |
{{ $env.VARNAME }} |
Environment variable | {{ $env.N8N_API_KEY }} |
{{ $vars.myVar }} |
Workflow‑scoped variable | {{ $vars.approvalLimit }} |
How do you reference data from other nodes using $json, $node, and $workflow?
Use {{ $json.field }} for the current node’s input item.
To read output from any preceding node, use
{{ $node["Node Name"].json.field }}. The
$workflow object provides metadata like workflow ID, name,
and the active environment. These variables are evaluated dynamically at
execution time.
[2]
$node accepts the node’s display name in double quotes.
For binary data, use $node["Node Name"].binary.fileName.
These references are essential for linking node outputs in
core n8n nodes like HTTP Request and Set.
How do double curly braces expressions work in n8n node parameters?
Any node parameter field in n8n accepts expressions inside
{{ }}. The expression is parsed at runtime, and the
resolved value replaces the placeholder. You can mix static text with
expressions: Hello {{ $json.firstName }}. Chaining
multiple expressions in a single string is allowed and evaluates
sequentially from left to right.
[1]
Expressions support 58 built‑in methods and objects,
including math operations, string manipulation, and date formatting.
If an expression fails—for example, referencing an undefined field—the
node returns an error. Wrap safe‑fallback logic with
{{ $if($json.field, $json.field, "default") }}.
For more on data transformation patterns, see the
Code node transformation guide.
How do you extract nested JSON data with JMESPath expressions in n8n?
n8n provides the $jmespath() function to query and filter
JSON using the JMESPath language. The first argument is the target JSON
object (usually $json), and the second is a JMESPath query
string. Example: {{ $jmespath($json, "items[?age>`18`].name") }}
returns an array of names of items where age is greater than 18.
[3]
JMESPath supports five projection types—list, slice, object, flatten,
and filter—that cover deeply nested API responses. For multi‑level
extraction, chain selectors: "response.data.orders[*].[id,total]".
If the query returns a complex object, n8n preserves its structure, so
you can further transform it with a
Code node or Set node.
How do you format dates and times using n8n’s Luxon DateTime expressions?
n8n globally exposes the Luxon DateTime library through $now,
$today, and any Luxon method. For instance,
{{ $now.plus({days: 7}).toISODate() }} adds seven
days and returns an ISO date string. You can also parse custom date
strings with DateTime.fromISO() or
DateTime.fromFormat().
[4]
The full Luxon API is available: diff() to compare dates,
setZone() for timezone conversion, and
toRelative() for human‑friendly durations like “3 days ago”.
Luxon is accessible from any expression field, eliminating the need for
a dedicated Code node for date arithmetic. For date‑based conditional
logic, combine with the
IF node guide.
$now inside a loop that executes many times;
compute the timestamp once in a Set node and reference it downstream.
How do you access environment variables and workflow variables with n8n expressions?
Environment variables are read with {{ $env.VARNAME }};
they must be defined on the n8n host or Docker container. Workflow‑scoped
variables ($vars) are set in the workflow settings and
accessed as {{ $vars.myKey }}. Both are evaluated at
runtime and never exposed in saved workflow JSON exports.
[2]
Use $vars for reusable thresholds, API base URLs, or
feature flags—they are strict key‑value pairs. Values can be numbers,
strings, or booleans, but not complex objects. Unlike $env,
$vars are accessible only within the workflow that defines
them, making them ideal for per‑workflow configuration. For secrets
management, external vaults are preferred; see
credential security.
How do you debug n8n expressions and avoid common evaluation errors?
The Expression Editor in n8n’s node parameters provides live preview—
expand the editor and click “Refresh” to see the resolved value. If an
expression returns [undefined], the referenced field does
not exist. Use {{ $if($json.field, $json.field, "N/A") }}
to provide fallback values and prevent node failures.
[5]
Prevent errors by validating data structure with the “Schema” tab in
the output panel, and use the $json?.field syntax (optional
chaining) to safely access nested keys. For multi‑step transformations,
break logic into multiple Set nodes rather than one giant expression.
For advanced debugging, consult
error workflow handling.

