Skip to content
New: a free website for your business, live in 48 to 72 hoursWorkflow automation on n8n and Claude, built for your businessFixed price, agreed before we start · Live in 5 to 10 business days30-day money-back guarantee on every planProfessional firms · Agencies · E-commerceYou own every workflow, in your own n8nClaude API: your data is not used for trainingHuman approval on every sensitive stepFree automation audit, no obligation
PURIST
30 days
Money-back window
14 h/wk
Modeled time saved
99.97%
Uptime SLA
< 7 days
Deploy time
PURIST AI
Claude Opus 4.7 · n8n v1.71 · <80ms
What type of business are you running? I'll show you exactly which processes we'd automate first and your estimated ROI.
Powered by n8n + Claude Opus 4.7 Get my free automation plan →
n8n Expression Errors Fixed: "Referenced node is unexecuted", "Can't get data" and More
Guides 7 min read · 1,466 words

n8n Expression Errors Fixed: "Referenced node is unexecuted", "Can't get data" and More

The n8n expression errors you meet most often, what each one really means, and the fix: unexecuted nodes, missing data, invalid JSON, syntax and paired items.

Steve, founder of PURIST

November 6, 2026

PURIST: Stuck on n8n? Our n8n experts fix and build workflows like this one, at a fixed price →

Expressions are the {{ }} snippets that pull data into node fields. They are short, so when one fails the error feels out of proportion: the whole node stops. Most failures fall into five families, and each has a clear fix.

In short. "Referenced node is unexecuted" and "Can't get data for expression" mean the node you reference has not run yet in this execution: run the workflow up to it, rewire so it runs first, or guard with $('Node').isExecuted. "Invalid JSON" means the JSON body is not valid once the expression is filled in. Webhook data lives under $json.body, not $json.

n8n Expression Errors Fixed: "Referenced node is unexecuted", "Can't get data" and More: workflow diagram
An expression can only read nodes that already ran in this execution. Illustration: PURIST.

1. "Referenced node is unexecuted" / "Can't get data for expression"

The documentation explains that n8n cannot retrieve data from a node that has not run in the current execution. The full message names the node:

An expression references the node 'Get customer', but it hasn't been executed yet. Either change the expression, or re-wire your workflow to make sure that node executes first.

Typical causes:

  • you are testing one node on its own, and the referenced node never ran in this test;
  • the referenced node is on another branch of an IF or Switch that did not run;
  • the referenced node comes after the current one.

Fixes:

  1. 1 Test the workflow up to the named node first, or pin its data.
  2. 2 Move the referenced node before the current one on the same path.
  3. 3 Guard the expression when the node is optional:
text
{{ $('Get customer').isExecuted ? $('Get customer').item.json.email : '' }}

2. "The 'JSON Output' in item 0 contains invalid JSON"

You used JSON mode (in Edit Fields, HTTP Request body and so on) and the result is not valid JSON. Two common reasons:

  • a syntax error: missing quotes, a trailing comma, unbalanced brackets;
  • an expression that inserts a value which breaks the JSON, for example text containing quotes, or undefined when a field is missing on some items.

Safer pattern for text values: let n8n encode them.

text
{
  "name": {{ JSON.stringify($json.name) }},
  "note": {{ JSON.stringify($json.note ?? '') }}
}

JSON.stringify adds the quotes and escapes special characters, so a name like O"Neil cannot break the body. Check the final JSON in a JSON linter, or compare a working and a failing body with our free JSON Diff Checker.

n8n Expression Errors Fixed: "Referenced node is unexecuted", "Can't get data" and More: node settings
Inserting text into JSON safely with JSON.stringify() and default values. Illustration: PURIST.

3. "Invalid syntax"

The expression itself is malformed. The documentation's example is a trailing dot: {{ $('If').item.json. }}. Other frequent ones: a missing closing }}, single { } instead of double, or a JavaScript keyword used as a field name without brackets. Test the expression in isolation with our n8n Expression Tester.

4. The value is empty although the data is there

Usually a wrong path rather than an error:

  • Webhook data arrives as body, headers, params and query. The email is {{ $json.body.email }}.
  • Field names with spaces or dashes need brackets: {{ $json["first name"] }}, {{ $json["next-page"] }}.
  • Arrays need an index: {{ $json.contacts[0].email }}.

Paste a sample of the input into our JSON Path Finder to get the exact path.

5. Paired item errors

When a node references $('Node').item but n8n cannot tell which input item produced the current one, you get errors about paired items. It happens after Code nodes that change the number of items, or after merges. Fixes:

  • use .first(), .last() or .all() when you do not need the matching item;
  • in Code nodes that create new items, keep the link by returning items derived from the input ones (the documentation's item linking section covers pairedItem);
  • restructure so the data you need is carried in the item itself, with an Edit Fields node, instead of looking back.

Writing longer logic in an expression

For multi-line logic, the documentation shows an immediately invoked function:

text
{{ (() => {
  const total = $json.items.reduce((s, i) => s + i.price * i.qty, 0);
  return total > 1000 ? 'priority' : 'standard';
})() }}

If the expression grows beyond a few lines, move it to a Code node or an Edit Fields node: it is easier to test and to read.

Worked example: one email node, two branches

A common workflow: a webhook receives a form, an IF checks whether the contact exists in the CRM, and both branches end in the same "Send email" node that greets the person by name.

  • True branch: "Get contact" (CRM) runs, so $('Get contact') has data.
  • False branch: "Create contact" (CRM) runs instead, and "Get contact" never runs.

If "Send email" uses {{ $('Get contact').item.json.firstname }}, every new contact triggers "Referenced node is unexecuted". Three clean fixes:

  1. 1 Guard the expression:
text
{{ $('Get contact').isExecuted ? $('Get contact').item.json.firstname : $('Create contact').item.json.firstname }}
  1. 1 Normalise before merging: add an Edit Fields node at the end of each branch that outputs the same field (firstname), then read {{ $json.firstname }} in the email node.
  2. 2 Read from the webhook, which always ran: {{ $('Webhook').item.json.body.firstname }}.

Option 2 is the most maintainable: each branch is responsible for producing the same shape, and the shared node does not need to know which branch ran.

Expressions, cheat sheet

NeedExpression
Current item field{{ $json.email }}
Field with a space{{ $json["first name"] }}
From a named node, linked item{{ $('Get contact').item.json.email }}
First item of a node{{ $('Get contact').first().json.email }}
Default if missing{{ $json.phone ?? 'not provided' }}
Today, formatted{{ $now.toFormat('yyyy-LL-dd') }}
Number of items from a node{{ $('Get contact').all().length }}
Safe JSON text{{ JSON.stringify($json.note) }}

Paired items, explained simply

When you write $('Node').item, n8n finds the item in that node that produced the current one, by following pairedItem links. Most nodes keep these links automatically. They break when a Code node creates brand new items, or after some merges, because n8n can no longer tell which input produced which output. Then use .first(), .last() or .all() when you do not need the matching item, or carry the needed field forward on the item itself with an Edit Fields node.

Troubleshooting table

MessageCauseFix
Referenced node is unexecutedNode did not run in this executionGuard with isExecuted, rewire, or normalise branches
Can't get data for expressionSame family; often testing one node aloneRun the workflow up to the node, or pin data
Invalid syntaxMalformed expressionCheck {{ }}, dots and brackets
JSON Output contains invalid JSONInserted values broke the JSONJSON.stringify() each inserted value
Paired item data unavailableItem links lost.first() / .all(), or carry data forward
Value is emptyWrong path$json.body... for webhooks; brackets for special names

Frequently asked questions

What does "Referenced node is unexecuted" mean in n8n?

The expression reads a node that has not run in the current execution. Run it first, rewire the workflow, or check $('Node').isExecuted before reading it.

Why is my n8n expression returning undefined?

The path is wrong for this data. Webhook fields are under $json.body, names with spaces need brackets, and arrays need an index.

How do I avoid invalid JSON when inserting text with an expression?

Wrap values with JSON.stringify(), which adds quotes and escapes characters such as quotes and line breaks.

Can I write several lines of JavaScript in an n8n expression?

Yes, wrapped in an immediately invoked function, as shown in the n8n documentation. For longer logic, prefer a Code node.

What is the difference between .item and .first() in n8n expressions?

.item returns the linked item that produced the current one. .first() always returns the first item of that node. Use .item when each item must match its source.

How do I check whether a node ran in an expression?

Use $('Node name').isExecuted, which returns true or false.

Why does my expression work in test but fail in production?

In a test you may run the whole path, so every node has data. In production, branches skip nodes, and some fields are missing on some items. Guard both cases.

Tags

n8nexpressionserrordebuggingjson
Steve, founder of PURIST

Steve founded PURIST, a workflow automation studio working with n8n, Make and Claude AI, and is the point of contact on every project. Prices and features in our articles come from vendor documentation and public pricing pages. How we research and score tools.

Complete guide

Automation Tools & Platforms

11 min read n8n Code Node: 15 JavaScript Examples You Can Copy and … 8 min read n8n Code Node With Multiple Inputs: 3 Methods That Work 7 min read Fix "Cannot find module" in the n8n Code Node (npm Pack… 7 min read n8n Code Node Errors Fixed: "Code doesn't return items … 7 min read $env and Credentials in the n8n Code Node: What Works a… 7 min read n8n Code Node Binary Data: Read, Change and Return File… 7 min read Python in the n8n Code Node (n8n 2.x): Setup, Syntax an… 7 min read Fix n8n "The requested webhook is not registered" (Test… 6 min read n8n Webhook URL: Test vs Production, and How to Change … 7 min read n8n Respond to Webhook: Return JSON, Status Codes, Redi… 8 min read Secure an n8n Webhook: Header Auth, Basic Auth, JWT and… 7 min read n8n Webhook Not Working? 10 Causes and How to Fix Each … 7 min read n8n HTTP Request Pagination: Every Pattern With Working… 7 min read n8n HTTP Request Authentication: API Keys, Bearer Token… 7 min read n8n HTTP Request Timeout and "Aborted" Errors: Causes a… 7 min read Upload and Download Files With the n8n HTTP Request Nod… 6 min read Fix ECONNREFUSED in n8n: Docker, localhost and 127.0.0.… 6 min read n8n 429 Too Many Requests: Batching, Retries and Rate L… 6 min read Fix redirect_uri_mismatch for n8n OAuth2 Credentials (G… 6 min read Anatomy Claude skill: what it is, how to install it, an… 5 min read How to explain a business process with the Anatomy skil… 5 min read Anatomy vs Mermaid vs Excalidraw: which to explain a wo… 14 min read n8n LinkedIn Job Automation: Auto-Apply, Track, and Fol… 16 min read n8n HTTP Request Node: Complete Documentation and Examp… 18 min read The future of automation: how our engineering team is s… 8 min read n8n vs Make vs Zapier: the honest comparison your busin… 11 min read n8n vs Make vs Zapier: an honest comparison for product… 7 min read Webhook vs polling: the architecture decision that dete… 24 min read n8n tutorial: build your first production workflow in u… 26 min read The 9 best Zapier alternatives in 2026: an honest ranki… 21 min read Make.com tutorial: build powerful automations without c… 19 min read Automation consultant vs DIY: how to decide what is rig… 14 min read n8n Self-Hosted vs Cloud: The Complete Decision Guide (… 15 min read 5 Zapier Free Alternatives That Handle Real Production … 15 min read WhatsApp Business Automation With n8n: Build a 24/7 Cus… 17 min read Google Workspace Automation: 15 Workflows for Sheets, D… 16 min read Claude AI for Business Automation: What It Does, What I… 15 min read Airtable Automation With n8n: 10 Workflows That Make Yo… 15 min read Droven.io AI Automation Tools: Full Review and Best Alt… 14 min read Droven.io RPA and Business Automation: An Honest 2026 R… 15 min read Enterprise Workflow Automation: The Complete Guide for … 13 min read Document Workflow Automation: Software, Implementation,… 14 min read Marketing Automation Workflow: From Content Creation to… 16 min read Ad Campaign Workflow Data Model and SDR Inbound Pipelin… 14 min read ComfyUI Workflows for Business: Product Photography, Ma… 13 min read GPT-5.2 for Business Workflows and the spec-workflow-mc… 17 min read ServiceNow vs IBM BAW vs n8n: Enterprise Workflow Autom… 16 min read 9 Best Workflow Automation Tools for Small Business in …

Keep reading

More from the blog.

All articles

From audit to deployment

Experience the automation
these articles are about.

Get my free automation plan →