Reference > Core Concepts

Expressions and Variables

Reference for n8n expression syntax, built-in variables, and data access patterns.

n8n expressions insert dynamic values into node parameters using double curly braces {{ }}. Anything inside the braces is evaluated as JavaScript at runtime and replaced with the result. Expressions read data from the current item with $json, from specific upstream nodes with $('Node Name'), and from built-in variables such as $now and $execution.id, so nodes react to data instead of using fixed values.

What is n8n expression syntax?

n8n uses double curly braces {{ }} to embed expressions in node parameters. Anything inside the braces is evaluated as JavaScript at runtime and replaced with the result.

{{ $json.firstName + ' ' + $json.lastName }}

Toggle a parameter field to Expression mode (the = icon) before entering an expression.

How do you access data from previous nodes?

Current Item

Variable Description
$json The json property of the current item from the immediately preceding node
$binary The binary property of the current item (file data)
$input.item.json Same as $json (explicit form)
{{ $json.email }}
{{ $json.address.city }}
{{ $json.tags[0] }}

Specific Upstream Node

Reference a node by name to access its output:

{{ $('Customer Lookup').item.json.name }}
{{ $('HTTP Request').first().json.id }}
{{ $('HTTP Request').all() }}

All Items

Method Returns
$input.all() Array of all items from the immediate parent
$input.first() The first item from the immediate parent
$('Node Name').all() All items from a named node

What built-in variables are available?

Variable Description
$now Current date/time as a Luxon DateTime object
$today Current date at midnight as a Luxon DateTime
$workflow.id ID of the current workflow
$workflow.name Name of the current workflow
$workflow.active Whether the workflow is active (true/false)
$execution.id ID of the current execution
$execution.mode manual or production
$execution.resumeUrl URL to resume a waiting execution
$runIndex How many times the current node has run in this execution (useful in loops)
$itemIndex Index of the current item in the input array
$position Same as $itemIndex

How do you use JavaScript in expressions?

Full JavaScript is available inside {{ }}. Common patterns:

{{ $json.price * 1.1 }}

{{ $json.status === 'active' ? 'Yes' : 'No' }}

{{ $json.tags.join(', ') }}

{{ new Date($json.timestamp).toISOString() }}

{{ $now.minus({ days: 7 }).toISO() }}

Warning

Expressions must be single-line evaluations that return a value. For multi-line logic, use the Code node instead.

What are common expression patterns?

Default value when field is missing:

{{ $json.nickname ?? $json.firstName ?? 'Unknown' }}

Format a date:

{{ $now.toFormat('yyyy-MM-dd') }}

Build a dynamic URL:

{{ 'https://api.example.com/users/' + $json.userId }}

Tip

Use the Expression Editor (click the field, then the expression tab) to get autocomplete suggestions and preview results against real execution data.

Related tips: Data Transformation, Code Node Mastery

What should you read next?

Showcase builds

19 complete workflows from my own projects, each with its n8n workflow JSON to import. Showcase entries link the file at the end of the article.

See the showcase builds

Keep reading

190 entries grouped by topic, from first workflow to queue mode. Free, no signup.

Browse the encyclopedia

Need it built?

I design, build and run n8n systems for clients. Every engagement starts with a $1,500 diagnostic audit, credited toward the build.

Book an introductory call