Back to Blog
Getting Started

Understanding n8n Data Flow: A Beginner's Guide

Eight University TeamJanuary 6, 20257 min read

Understanding n8n Data Flow: A Beginner's Guide

One of the most important concepts to master in n8n is understanding how data flows through your workflows. Once you grasp this, building complex automations becomes much easier.

The Basics: Items and JSON

In n8n, data travels between nodes as items. Each item is a JSON object containing your data. Think of items like rows in a spreadsheet - each one holds a piece of information.

Example: A single item

{
  "json": {
    "name": "John Doe",
    "email": "john@example.com",
    "orderId": "ORD-123"
  }
}

When a node outputs multiple records (like fetching a list of customers), you get multiple items:

[
  { "json": { "name": "John", "email": "john@example.com" } },
  { "json": { "name": "Jane", "email": "jane@example.com" } },
  { "json": { "name": "Bob", "email": "bob@example.com" } }
]

How Data Flows Between Nodes

Each node in n8n:

  1. Receives data from the previous node (input)
  2. Processes that data (transform, filter, enrich)
  3. Outputs data to the next node
[Webhook] → [Set Node] → [IF Node] → [HTTP Request] → [Email]
    |            |            |             |            |
  Input      Transform     Filter        Enrich       Output

Accessing Data with Expressions

Use expressions to access data from previous nodes:

Current item's data:

{{ $json.email }}
{{ $json.customer.name }}

Previous node's data:

{{ $('Set Node').item.json.email }}

All items from a node:

{{ $('HTTP Request').all() }}

Understanding Data Transformation

The Set Node

The Set node lets you reshape data:

Input:

{
  "firstName": "John",
  "lastName": "Doe",
  "emailAddress": "john@example.com"
}

After Set Node (renaming fields):

{
  "name": "John Doe",
  "email": "john@example.com"
}

The Code Node

For complex transformations, use JavaScript:

return $input.all().map(item => ({
  json: {
    fullName: `${item.json.firstName} ${item.json.lastName}`,
    email: item.json.emailAddress.toLowerCase(),
    createdAt: new Date().toISOString()
  }
}));

Common Data Flow Patterns

Pattern 1: One-to-One

Each input item produces one output item:

Input: 3 customers → Transform → Output: 3 transformed customers

Pattern 2: One-to-Many (Split)

One input item produces multiple output items:

Input: 1 order with 5 line items → Split → Output: 5 items

Use the "Split Out" node or Code node to split:

const items = [];
for (const lineItem of $json.order.lineItems) {
  items.push({
    json: {
      orderId: $json.order.id,
      ...lineItem
    }
  });
}
return items;

Pattern 3: Many-to-One (Aggregate)

Multiple input items become one output item:

Input: 100 orders → Aggregate → Output: 1 summary

Use the "Aggregate" node or Code node:

const allItems = $input.all();
const total = allItems.reduce((sum, item) => sum + item.json.amount, 0);

return [{
  json: {
    totalOrders: allItems.length,
    totalAmount: total,
    averageOrder: total / allItems.length
  }
}];

Debugging Data Flow

Check Node Outputs

Click on any executed node to see:

  • Input data: What the node received
  • Output data: What the node produced

Use the Edit Fields Node

Add a temporary "Edit Fields" node to inspect data at any point in your workflow.

Common Issues

"Cannot read property of undefined" The field doesn't exist. Use optional chaining:

{{ $json.customer?.email ?? 'no email' }}

Empty output Check that previous nodes are producing data. Look at the input of the failing node.

Wrong data type Convert types explicitly:

const count = parseInt($json.quantity, 10);
const isActive = $json.status === 'active';

Best Practices

  1. Check data at each step - Verify output before adding more nodes
  2. Use meaningful field names - Makes expressions easier to read
  3. Handle missing data - Always provide fallbacks
  4. Keep transformations simple - One transformation per node when possible

Conclusion

Understanding data flow is fundamental to building effective n8n workflows. Remember: data flows as items, each item is JSON, and you control the transformation at every step.

Want to master data manipulation in n8n? Our courses include hands-on exercises for transforming, splitting, and aggregating data.

Ready to Learn More?

Check out our comprehensive n8n courses to master workflow automation.