Yapay Zeka Ajanları
n8n Learning Path
CHAPTER 03Beginner ~75 min

Expressions and Data Manipulation

The most powerful feature of n8n: expressions. Read, transform and format data between nodes.

In this chapter

Expressions are where n8n goes from 'just a trigger-action tool' to 'a real automation platform.' Reading, transforming, formatting and conditioning data between nodes — all of it goes through expressions. In this chapter you will learn the syntax, the most-used transforms (string, number, date) and how to pull data from multiple nodes.

Topics

  • Expression syntax: {{ $json.field }}
  • Pulling data across nodes: $node, $items
  • String, Number, Date conversions
  • JMESPath for complex queries
  • Date/time math and formats
  • Conditional values (ternary)

Expression syntax: {{ ... }}

To switch a parameter field into expression mode, press the 'fx' button at the top right (or type =, then {{). Expressions are JavaScript: {{ $json.email }} returns the email field of the current item, {{ $json.name.toLowerCase() }} returns it lowercased. Two tips: the expression box shows the value's type (string/number/object) — verify it; if a field name has spaces, use bracket notation: $json['Full Name'].

Data between nodes: $json, $input, $node

Three core references. $json: the current node's incoming item json — the one you use most. $input.first(), $input.last(), $input.all(): access all items coming into the current node. $node['Webhook'].json.body.email: reach into the output of any other node by name (useful after if/merge to reach back). Once these three click, you stop thinking about where to fetch data from.

Webhook
Set
Edit Fields
{ }HTTP Request

String operations

The ones you will reach for the most: .trim() (strip whitespace), .toLowerCase() / .toUpperCase(), .split(',') (CSV to array), .replace('old', 'new'), .includes('needle'), template literals (`Hello ${$json.name}!`). Example: {{ $json.email.toLowerCase().trim() }} — normalises an email from a form.

Number, Date and Math

Number: parseInt($json.qty) or Number($json.qty) to coerce strings; toFixed(2) for 2 decimals. Date: $now (right now), $today (today at 00:00), DateTime.fromISO($json.created_at) to parse an ISO string. .plus({days: 7}), .minus({hours: 1}), .toFormat('dd.MM.yyyy') — the full Luxon DateTime API is available. Math: Math.max, Math.round, Math.random — full JavaScript Math.

JMESPath for complex JSON

When dealing with deeply nested JSON, JMESPath can be much cleaner than expressions. $jmespath($json, 'items[?status==`active`].name') returns the names of active items. It is a first-class function in n8n; useful for filtering and reshaping API responses.

Conditional values (ternary)

Use ternary to condition a value: {{ $json.score > 70 ? 'hot' : 'cold' }}. More readable: {{ $json.email ? $json.email : 'unknown@example.com' }} — or shorter with nullish coalescing: {{ $json.email ?? 'unknown@example.com' }}. Doing small transforms inline keeps the workflow clean instead of inserting an IF node.

This chapter's workflow (n8n editor view)

Webhook
Edit Fields (expression)
Set