N8N Expression Syntax

Fix n8n expression errors with expert syntax validation and patterns

✨ The solution you've been looking for

Verified
Tested and verified by our team
16036 Stars

Validate n8n expression syntax and fix common errors. Use when writing n8n expressions, using {{}} syntax, accessing $json/$node variables, troubleshooting expression errors, or working with webhook data in workflows.

n8n workflow-automation expressions syntax validation webhook troubleshooting
Repository

See It In Action

Interactive preview & real-world examples

Live Demo
Skill Demo Animation

AI Conversation Simulator

See how users interact with this skill

User Prompt

I'm trying to access the email field from a webhook in n8n but {{$json.email}} isn't working

Skill Processing

Analyzing request...

Agent Response

Learn that webhook data is nested under .body and get the correct syntax: {{$json.body.email}}

Quick Start (3 Steps)

Get up and running in minutes

1

Install

claude-code skill install n8n-expression-syntax

claude-code skill install n8n-expression-syntax
2

Config

3

First Trigger

@n8n-expression-syntax help

Commands

CommandDescriptionRequired Args
@n8n-expression-syntax fix-webhook-data-accessCorrectly access data from webhooks by understanding the proper nested structureNone
@n8n-expression-syntax reference-other-nodesProperly access data from previous nodes in your workflow with correct syntaxNone
@n8n-expression-syntax validate-expression-syntaxCheck and fix common n8n expression syntax errors before they break your workflowNone

Typical Use Cases

Fix Webhook Data Access

Correctly access data from webhooks by understanding the proper nested structure

Reference Other Nodes

Properly access data from previous nodes in your workflow with correct syntax

Validate Expression Syntax

Check and fix common n8n expression syntax errors before they break your workflow

Overview

n8n Expression Syntax

Expert guide for writing correct n8n expressions in workflows.


Expression Format

All dynamic content in n8n uses double curly braces:

{{expression}}

Examples:

✅ {{$json.email}}
✅ {{$json.body.name}}
✅ {{$node["HTTP Request"].json.data}}
❌ $json.email  (no braces - treated as literal text)
❌ {$json.email}  (single braces - invalid)

Core Variables

$json - Current Node Output

Access data from the current node:

1{{$json.fieldName}}
2{{$json['field with spaces']}}
3{{$json.nested.property}}
4{{$json.items[0].name}}

$node - Reference Other Nodes

Access data from any previous node:

1{{$node["Node Name"].json.fieldName}}
2{{$node["HTTP Request"].json.data}}
3{{$node["Webhook"].json.body.email}}

Important:

  • Node names must be in quotes
  • Node names are case-sensitive
  • Must match exact node name from workflow

$now - Current Timestamp

Access current date/time:

1{{$now}}
2{{$now.toFormat('yyyy-MM-dd')}}
3{{$now.toFormat('HH:mm:ss')}}
4{{$now.plus({days: 7})}}

$env - Environment Variables

Access environment variables:

1{{$env.API_KEY}}
2{{$env.DATABASE_URL}}

🚨 CRITICAL: Webhook Data Structure

Most Common Mistake: Webhook data is NOT at the root!

Webhook Node Output Structure

 1{
 2  "headers": {...},
 3  "params": {...},
 4  "query": {...},
 5  "body": {           // ⚠️ USER DATA IS HERE!
 6    "name": "John",
 7    "email": "john@example.com",
 8    "message": "Hello"
 9  }
10}

Correct Webhook Data Access

1 WRONG: {{$json.name}}
2 WRONG: {{$json.email}}
3
4 CORRECT: {{$json.body.name}}
5 CORRECT: {{$json.body.email}}
6 CORRECT: {{$json.body.message}}

Why: Webhook node wraps incoming data under .body property to preserve headers, params, and query parameters.


Common Patterns

Access Nested Fields

 1// Simple nesting
 2{{$json.user.email}}
 3
 4// Array access
 5{{$json.data[0].name}}
 6{{$json.items[0].id}}
 7
 8// Bracket notation for spaces
 9{{$json['field name']}}
10{{$json['user data']['first name']}}

Reference Other Nodes

1// Node without spaces
2{{$node["Set"].json.value}}
3
4// Node with spaces (common!)
5{{$node["HTTP Request"].json.data}}
6{{$node["Respond to Webhook"].json.message}}
7
8// Webhook node
9{{$node["Webhook"].json.body.email}}

Combine Variables

 1// Concatenation (automatic)
 2Hello {{$json.body.name}}!
 3
 4// In URLs
 5https://api.example.com/users/{{$json.body.user_id}}
 6
 7// In object properties
 8{
 9  "name": "={{$json.body.name}}",
10  "email": "={{$json.body.email}}"
11}

When NOT to Use Expressions

❌ Code Nodes

Code nodes use direct JavaScript access, NOT expressions!

 1// ❌ WRONG in Code node
 2const email = '={{$json.email}}';
 3const name = '{{$json.body.name}}';
 4
 5// ✅ CORRECT in Code node
 6const email = $json.email;
 7const name = $json.body.name;
 8
 9// Or using Code node API
10const email = $input.item.json.email;
11const allItems = $input.all();

❌ Webhook Paths

1// ❌ WRONG
2path: "{{$json.user_id}}/webhook"
3
4// ✅ CORRECT
5path: "user-webhook"  // Static paths only

❌ Credential Fields

1// ❌ WRONG
2apiKey: "={{$env.API_KEY}}"
3
4// ✅ CORRECT
5Use n8n credential system, not expressions

Validation Rules

1. Always Use {{}}

Expressions must be wrapped in double curly braces.

1 $json.field
2 {{$json.field}}

2. Use Quotes for Spaces

Field or node names with spaces require bracket notation:

1 {{$json.field name}}
2 {{$json['field name']}}
3
4 {{$node.HTTP Request.json}}
5 {{$node["HTTP Request"].json}}

3. Match Exact Node Names

Node references are case-sensitive:

1 {{$node["http request"].json}}  // lowercase
2 {{$node["Http Request"].json}}  // wrong case
3 {{$node["HTTP Request"].json}}  // exact match

4. No Nested {{}}

Don’t double-wrap expressions:

1 {{{$json.field}}}
2 {{$json.field}}

Common Mistakes

For complete error catalog with fixes, see COMMON_MISTAKES.md

Quick Fixes

MistakeFix
$json.field{{$json.field}}
{{$json.field name}}{{$json['field name']}}
{{$node.HTTP Request}}{{$node["HTTP Request"]}}
{{{$json.field}}}{{$json.field}}
{{$json.name}} (webhook){{$json.body.name}}
'={{$json.email}}' (Code node)$json.email

Working Examples

For real workflow examples, see EXAMPLES.md

Example 1: Webhook to Slack

Webhook receives:

1{
2  "body": {
3    "name": "John Doe",
4    "email": "john@example.com",
5    "message": "Hello!"
6  }
7}

In Slack node text field:

New form submission!

Name: {{$json.body.name}}
Email: {{$json.body.email}}
Message: {{$json.body.message}}

Example 2: HTTP Request to Email

HTTP Request returns:

1{
2  "data": {
3    "items": [
4      {"name": "Product 1", "price": 29.99}
5    ]
6  }
7}

In Email node (reference HTTP Request):

Product: {{$node["HTTP Request"].json.data.items[0].name}}
Price: ${{$node["HTTP Request"].json.data.items[0].price}}

Example 3: Format Timestamp

 1// Current date
 2{{$now.toFormat('yyyy-MM-dd')}}
 3// Result: 2025-10-20
 4
 5// Time
 6{{$now.toFormat('HH:mm:ss')}}
 7// Result: 14:30:45
 8
 9// Full datetime
10{{$now.toFormat('yyyy-MM-dd HH:mm')}}
11// Result: 2025-10-20 14:30

Data Type Handling

Arrays

1// First item
2{{$json.users[0].email}}
3
4// Array length
5{{$json.users.length}}
6
7// Last item
8{{$json.users[$json.users.length - 1].name}}

Objects

1// Dot notation (no spaces)
2{{$json.user.email}}
3
4// Bracket notation (with spaces or dynamic)
5{{$json['user data'].email}}

Strings

1// Concatenation (automatic)
2Hello {{$json.name}}!
3
4// String methods
5{{$json.email.toLowerCase()}}
6{{$json.name.toUpperCase()}}

Numbers

1// Direct use
2{{$json.price}}
3
4// Math operations
5{{$json.price * 1.1}}  // Add 10%
6{{$json.quantity + 5}}

Advanced Patterns

Conditional Content

1// Ternary operator
2{{$json.status === 'active' ? 'Active User' : 'Inactive User'}}
3
4// Default values
5{{$json.email || 'no-email@example.com'}}

Date Manipulation

1// Add days
2{{$now.plus({days: 7}).toFormat('yyyy-MM-dd')}}
3
4// Subtract hours
5{{$now.minus({hours: 24}).toISO()}}
6
7// Set specific date
8{{DateTime.fromISO('2025-12-25').toFormat('MMMM dd, yyyy')}}

String Manipulation

1// Substring
2{{$json.email.substring(0, 5)}}
3
4// Replace
5{{$json.message.replace('old', 'new')}}
6
7// Split and join
8{{$json.tags.split(',').join(', ')}}

Debugging Expressions

Test in Expression Editor

  1. Click field with expression
  2. Open expression editor (click “fx” icon)
  3. See live preview of result
  4. Check for errors highlighted in red

Common Error Messages

“Cannot read property ‘X’ of undefined” → Parent object doesn’t exist → Check your data path

“X is not a function” → Trying to call method on non-function → Check variable type

Expression shows as literal text → Missing {{ }} → Add curly braces


Expression Helpers

Available Methods

String:

  • .toLowerCase(), .toUpperCase()
  • .trim(), .replace(), .substring()
  • .split(), .includes()

Array:

  • .length, .map(), .filter()
  • .find(), .join(), .slice()

DateTime (Luxon):

  • .toFormat(), .toISO(), .toLocal()
  • .plus(), .minus(), .set()

Number:

  • .toFixed(), .toString()
  • Math operations: +, -, *, /, %

Best Practices

✅ Do

  • Always use {{ }} for dynamic content
  • Use bracket notation for field names with spaces
  • Reference webhook data from .body
  • Use $node for data from other nodes
  • Test expressions in expression editor

❌ Don’t

  • Don’t use expressions in Code nodes
  • Don’t forget quotes around node names with spaces
  • Don’t double-wrap with extra {{ }}
  • Don’t assume webhook data is at root (it’s under .body!)
  • Don’t use expressions in webhook paths or credentials

  • n8n MCP Tools Expert: Learn how to validate expressions using MCP tools
  • n8n Workflow Patterns: See expressions in real workflow examples
  • n8n Node Configuration: Understand when expressions are needed

Summary

Essential Rules:

  1. Wrap expressions in {{ }}
  2. Webhook data is under .body
  3. No {{ }} in Code nodes
  4. Quote node names with spaces
  5. Node names are case-sensitive

Most Common Mistakes:

  • Missing {{ }} → Add braces
  • {{$json.name}} in webhooks → Use {{$json.body.name}}
  • {{$json.email}} in Code → Use $json.email
  • {{$node.HTTP Request}} → Use {{$node["HTTP Request"]}}

For more details, see:


Need Help? Reference the n8n expression documentation or use n8n-mcp validation tools to check your expressions.

What Users Are Saying

Real feedback from the community

Environment Matrix

Dependencies

n8n workflow automation platform

Framework Support

n8n ✓ (recommended) Luxon DateTime library ✓

Context Window

Token Usage ~3K-8K tokens for complex workflow expressions

Security & Privacy

Information

Author
davila7
Updated
2026-01-30
Category
cms-platforms