Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Using Expressions in n8n | Introduction to n8n
n8n Overview

Using Expressions in n8n

Stryg for at vise menuen

Expressions in n8n let you dynamically customize data, automate decisions, and perform calculations within your workflows. An expression in n8n is written inside double curly braces, such as {{ $json["email"] }}. Expressions use JavaScript syntax, allowing you to reference and manipulate data from previous nodes, format values, and apply logic. For example, you might use an expression to insert a user's name from a previous step into an email template, or to calculate a value before passing it along to the next node.

Accessing fields
expand arrow

Use expressions like {{ $json["firstName"] }} to pull in data from previous nodes.

Formatting dates
expand arrow

Apply JavaScript date functions to format timestamps, such as {{ new Date($json["createdAt"]).toLocaleDateString() }}.

Conditional logic
expand arrow

Return different values based on conditions, for example {{ $json["score"] > 80 ? "Pass" : "Fail" }}.

Suppose you have a node that outputs a user's details, and you want to create a personalized greeting. Before using an expression, your message might look like this: "Hello, user!". By adding an expression such as {{ $json["firstName"] }}, you can change the message to: "Hello, John!" if the firstName field is "John". You can also manipulate data, for instance, to combine fields: {{ $json["firstName"] + " " + $json["lastName"] }} results in "John Doe". This approach helps you tailor workflow outputs based on data flowing through your automation.

Note
Note

To test and troubleshoot expressions in n8n, use the "Execute Node" feature to run individual nodes and inspect their output. If an expression does not behave as expected, check for typos, ensure the referenced fields exist, and use the Expression Editor's preview to see real-time results.

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 7

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

Sektion 1. Kapitel 7
some-alt