ef5pzVYFawTCu9tvWRktR3ENQXeOQWpVEekNlr4z
Bookmark

List of All n8n Expressions Explained

Navigating n8n expressions can feel a bit like spelunking in a cave full of JavaScript-powered treasures — powerful, a bit dark at first, but ultimately transformative once you know what to look for. Whether you're building simple automation or chaining together complex decision-making workflows, expressions in n8n are the connective tissue that brings it all to life. To save you countless hours of trial and error, this guide presents a complete, easy-to-copy list of all n8n mapping expressions — fully explained, categorised, and ready to drop straight into your workflows.

1. Accessing JSON and Item Data

Use these expressions to get data from the current item or another item in a workflow.
  • Current field value:
    {{$json["fieldName"]}}
  • First item from a node:
    {{$item(0).json["fieldName"]}}
  • All items from a specific node:
    {{$items("Node Name")}}
  • Specific item data:
    {{$item(index).json}}

2. Referencing Other Nodes

Grab values from other nodes’ outputs or settings.
  • Value from another node:
    {{$node["Webhook"].json["email"]}}
  • Parameter value from another node:
    {{$node["HTTP Request"].parameter["url"]}}

3. Parameters and Environment Variables

Handy when working with custom inputs or .env files.
  • Node parameter:
    {{$parameter["fieldName"]}}
  • Environment variable:
    {{$env["MY_SECRET_KEY"]}}

4. Context, Global, and Workflow Storage

Great for storing temporary or shared values during execution.
  • Local node storage:
    {{$context["key"]}}
  • Global workflow storage:
    {{$global["key"]}}
  • Shared workflow data:
    {{$workflowData["key"]}}

5. Time and Date Expressions (Luxon)

Date manipulation is seamless with Luxon built-in.
  • Current ISO timestamp:
    {{ DateTime.now().toISO() }}
  • Format an existing date:
    {{ DateTime.fromISO($json["date"]).toFormat("yyyy LLL dd") }}
  • Add days to current date:
    {{ DateTime.now().plus({ days: 3 }).toISODate() }}

6. Useful JavaScript Utilities

Apply basic transformations or logic in your expressions.
  • To uppercase:
    {{$json["name"].toUpperCase()}}
  • With fallback/default value:
    {{$json["email"] || "no@email.com"}}
  • Optional chaining:
    {{$json?.user?.name || "Unknown"}}
  • Condition check:
    {{$json["status"] === "active" ? "Yes" : "No"}}

7. Execution and Workflow Metadata

Pull metadata about the current execution context.
  • Workflow name:
    {{$workflow.name}}
  • Workflow ID:
    {{$workflow.id}}
  • Execution ID:
    {{$execution.id}}
  • Execution mode:
    {{$execution.mode}}

8. Binary Data

Only applies when you’re handling files.
  • Access binary content:
    {{$binary}}
  • Get file name:
    {{$binary["data"].fileName}}

9. Expression Evaluation and Extras

Sometimes you need to dynamically evaluate or manipulate structures.
  • Evaluate string as expression:
    {{$evaluateExpression("2 + 2")}}
  • Keys of a JSON object:
    {{ Object.keys($json) }}
  • Count items in an array:
    {{ $json["items"].length }}
  • Join values:
    {{ [$json["first"], $json["last"]].join(" ") }}

Conclusion

Understanding and mastering these expressions can significantly accelerate your workflow automation in n8n. They allow you to inject logic, access external data, transform structures, and dynamically drive your entire flow — all from within the expression editor. Bookmark this list, refer back whenever needed, and soon these expressions will become second nature.

Frequently Asked Questions (FAQs)

Can I use JavaScript in n8n expressions? Yes, n8n expressions are powered by JavaScript, allowing you to use logic, math, and string methods.
What's the difference between $json and $node? $json refers to the current item's data, while $node["NodeName"] accesses data from another node.
How do I format dates in n8n? Use the built-in Luxon library like DateTime.now().toISO() or convert with DateTime.fromISO().
Can I save values between nodes? Yes! Use $context, $global, or $workflowData for storing and sharing values.
Are these expressions safe for production use? Absolutely. These are the officially supported and most stable expression types available in n8n.
Post a Comment

Post a Comment

You are welcome to share your ideas and thoughts in the comments!