n8n Expressions Cheat Sheet: The Syntax You'll Actually Use


n8n expressions are what make workflows genuinely dynamic. They let you take data from previous steps, transform values, work with dates, add conditions, and build logic directly inside your workflow.

The problem is that expression syntax can be easy to forget, especially when you haven’t used a particular pattern for a while.

Here’s a practical n8n expressions cheat sheet covering some of the patterns you’re most likely to use, along with a simple example for each.

Referencing Previous Node Data

Access data from the current node:

{{ $json.fieldName }}

This is useful when the value you need is already part of the input data available to the current node.

Access data from a specific node:

{{ $node["Node Name"].json.fieldName }}

Use this when you need to explicitly reference the output of a particular node rather than the current node’s input.

Access the complete JSON object:

{{ $json }}

This gives you access to the complete JSON data available to the current item.

Working with Dates

Get the current timestamp:

{{ $now }}

Useful when you need the current date or time inside a workflow.

Format the current date:

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

This is useful when you need a consistent date format for filenames, database records, emails, or other workflow data.

Add days to the current date:

{{ $now.plus({ days: 7 }) }}

For example, this can be useful when calculating a follow-up date, deadline, or reminder date.

String Manipulation

Combine two strings:

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

A simple way to combine values such as a first name and last name into a single string.

Convert text to uppercase:

{{ $json.text.toUpperCase() }}

Remove whitespace from the beginning and end:

{{ $json.text.trim() }}

This is particularly useful when working with form submissions or API data where users may accidentally include extra spaces.

Conditional Logic Within an Expression

Use a simple ternary condition:

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

This checks whether the status is active. If it is, the expression returns Yes; otherwise, it returns No.

Check whether a field contains a value:

{{ $json.email ? $json.email : 'no-email-provided' }}

This returns the email address when one exists and a fallback value when it does not.

Array and Object Handling

Access an item at a specific array index:

{{ $json.items[0].name }}

Array indexes start at 0, so [0] refers to the first item.

Count the number of items in an array:

{{ $json.items.length }}

Join an array into a single string:

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

For example, an array containing ["n8n", "automation", "AI"] would become a comma-separated string.

Useful Built-In Variables

$workflow — provides access to workflow-related metadata, such as the workflow name and ID.

$execution — provides information about the current workflow execution, including execution metadata and mode.

$itemIndex — gives you the index of the current item being processed. This can be useful when working with multiple items in a workflow.

Common Mistakes to Avoid

Forgetting the {{ }} wrapper — When using an expression in a field that supports expressions, make sure the expression is wrapped correctly. Otherwise, n8n may treat the content as literal text instead of evaluating it.

Confusing $json with a specific node reference — $json generally refers to the JSON data available to the current item, while a node-specific reference is used when you explicitly want data from another named node.

Assuming every field exists — Expressions can fail when they try to access a property that isn’t present or has an unexpected value. When working with external APIs or user-submitted data, consider adding appropriate fallback logic.

A Simple Way to Remember Expressions

When you get stuck, think about what you’re trying to do in three steps:

  1. Where is the data? Use $json or a specific node reference.
  2. What do I want to do with it? Format, transform, compare, combine, or calculate.
  3. What should happen if the value is missing? Add a fallback or condition where necessary.

This simple approach covers a surprising number of everyday n8n expression problems.

Wrap-Up

You don’t need to memorize every n8n expression. A relatively small set of patterns covers most of the practical situations you’ll encounter while building workflows.

Keep this cheat sheet handy when you’re working with JSON data, dates, strings, arrays, or conditional logic. Once you use these expressions regularly, the syntax starts to become second nature.

Comments

Popular posts from this blog

How to Automate Lead Qualification with n8n + OpenAI [Step-by-Step + Free Template]

5 Best n8n Alternatives in 2026 (Free & Paid Compared)

How to Automate Customer Support with AI Chatbots + n8n [No-Code Guide]