Reference > Core Concepts

Expressions and Variables

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

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.

Accessing 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

Built-in Variables

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

Using 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.

Common 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

See Also

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

191 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 a 20-minute call