N8n Expression Syntax
Master n8n expression syntax to build dynamic and powerful automation integrations
N8n Expression Syntax is a community skill for writing expressions in n8n workflow automation, covering JavaScript-based expressions, data referencing, built-in functions, conditional logic, and dynamic value construction for workflow node configuration.
What Is This?
Overview
N8n Expression Syntax provides tools for writing dynamic expressions within n8n workflow nodes. It covers JavaScript-based expressions that use double-brace syntax to embed code within node fields, data referencing that accesses output values from previous nodes using items and node reference patterns, built-in functions for string manipulation, date formatting, and array processing, conditional logic using ternary operators to route data based on field values, and dynamic value construction that combines static text with referenced data from upstream nodes. The skill enables users to create flexible workflows without custom code nodes.
Who Should Use This
This skill serves workflow automation builders configuring n8n node parameters, integration specialists connecting services through n8n pipelines, and operations teams building dynamic data transformations in automated processes.
Why Use It?
Problems It Solves
Static node configurations cannot adapt to varying input data that flows through automated workflows. Referencing data from earlier workflow steps requires understanding the specific expression syntax that n8n uses for node output access. Complex data transformations often require adding separate code nodes when expressions could handle the logic inline. Date and string formatting varies across connected services requiring conversion expressions at integration points.
Core Highlights
Expression evaluator processes JavaScript code within double-brace delimiters in node fields. Data accessor retrieves values from previous nodes using structured reference patterns. Function library provides built-in helpers for common data transformation operations. Logic builder creates conditional expressions for dynamic routing and value selection.
How to Use It?
Basic Usage
// n8n expression examples
// Reference previous node
{{ $json.email }}
// Access nested data
{{ $json.user.name }}
// Reference specific node
{{ $node['HTTP Request']
.json.data.id }}
// String concatenation
{{ 'Hello ' +
$json.firstName +
' ' +
$json.lastName }}
// Conditional value
{{ $json.status === 'active'
? 'Enabled'
: 'Disabled' }}
// Date formatting
{{ $now.format(
'yyyy-MM-dd') }}
// Number formatting
{{ $json.price
.toFixed(2) }}
// Array access
{{ $json.items[0].name }}
// Default fallback
{{ $json.nickname
|| $json.name
|| 'Unknown' }}
// Template literal
{{ `Order #${$json.id}`
+ ` - ${$json.total}` }}Real-World Examples
// Data transformation
// Build API request body
{
"name":
"{{ $json.first_name }}"
+ " "
+ "{{ $json.last_name }}",
"email":
"{{ $json.email
.toLowerCase() }}",
"created":
"{{ $now.toISO() }}",
"tier":
"{{ $json.spend > 1000
? 'premium'
: $json.spend > 100
? 'standard'
: 'basic' }}",
"tags":
"{{ $json.categories
.join(', ') }}"
}
// Multi-node data merge
// Combine customer and
// order data from two nodes
{
"customer":
"{{ $node['Get Customer']
.json.name }}",
"order_id":
"{{ $node['Get Order']
.json.id }}",
"total":
"{{ $node['Get Order']
.json.items
.reduce(
(sum, item) =>
sum + item.price,
0)
.toFixed(2) }}",
"priority":
"{{ $node['Get Customer']
.json.vip
? 'high'
: 'normal' }}"
}Advanced Tips
Use the items reference pattern to access data from nodes that output multiple items for individual processing in downstream expressions. Chain built-in string methods like trim, toLowerCase, and replace to clean data before passing it to external APIs. Use the $if helper for multi-branch conditionals that would be hard to read as nested ternary operators.
When to Use It?
Use Cases
Build dynamic API request bodies that pull field values from multiple previous workflow nodes. Create conditional notification messages that format differently based on event severity or data type. Transform date formats between services that use different timestamp representations in their respective APIs.
Related Topics
n8n workflows, JavaScript expressions, workflow automation, data transformation, node configuration, integration platforms, and low-code automation.
Important Notes
Requirements
n8n workflow platform with expression support enabled in node field configuration. Basic JavaScript knowledge for writing expressions beyond simple field references. Understanding of the upstream node output structure for accurate data referencing.
Usage Recommendations
Do: test expressions using the expression editor preview to verify output before running complete workflows. Use fallback values with the logical OR operator to handle missing or null fields gracefully. Keep individual expressions simple and move complex logic to dedicated code nodes for maintainability.
Don't: chain more than three ternary operators in a single expression since readability degrades quickly. Reference node outputs by index position instead of node name since workflow modifications can shift positions. Assume input data types without explicit conversion since upstream nodes may return strings where numbers are expected.
Limitations
Expressions execute within a sandboxed JavaScript environment with restricted access to external modules and system resources. Complex data processing that requires loops or multi-step logic exceeds what inline expressions can handle cleanly. Expression evaluation errors surface at runtime rather than during workflow design, requiring thorough testing with representative sample data.
More Skills You Might Like
Explore similar skills to enhance your workflow
Aspire
.NET Aspire development for building automated cloud-native applications and distributed system integration
Building Adversary Infrastructure Tracking System
Build an automated system to track adversary infrastructure using passive DNS, certificate transparency, WHOIS
Draft Nda
Draft a detailed Non-Disclosure Agreement between two parties covering information types, jurisdiction, and clauses needing legal review. Use when
Building Secure Contracts
Smart contract security toolkit with vulnerability scanners for 6 blockchains
Verification Before Completion
Run verification commands and confirm output before claiming success
Architecture Diagram Creator
Create comprehensive HTML architecture diagrams showing data flows, business objectives, features, technical architecture, and deployment. Use when us