Course/Chapter 1/5. Understanding n8n Data Structure
    beginner
    Chapter 1: Introduction to n8n

    5. Understanding n8n Data Structure

    Learn how n8n passes data between nodes using items and JSON.

    8m Lesson 5 of 5

    Understanding n8n's data structure is crucial for building effective workflows. Every piece of data in n8n flows as items — arrays of JSON objects.

    Items

    Each node receives and outputs an array of items. Each item is a JSON object with a `json` property containing the actual data.

    Binary Data

    Files and attachments are stored as binary data alongside JSON data. Each item can have both `json` and `binary` properties.

    Referencing Data

    Use expressions to access data from the current or previous nodes: - `$json.fieldName` — Current item's JSON field - `$input.all()` — All input items - `$node["NodeName"].json.field` — Specific node's output

    Code Examples

    n8n Item Structure
    json
    // Each item in n8n looks like this:
    {
      "json": {
        "name": "John Doe",
        "email": "john@example.com",
        "age": 30
      },
      "binary": {
        "attachment": {
          "data": "base64...",
          "mimeType": "application/pdf",
          "fileName": "report.pdf"
        }
      }
    }
    Common Expressions
    javascript
    // Access current item field
    {{ $json.email }}
    
    // Access nested field
    {{ $json.address.city }}
    
    // Access all items from input
    {{ $input.all() }}
    
    // Access specific node output
    {{ $node["HTTP Request"].json.data }}
    
    // Use JavaScript functions
    {{ $json.name.toUpperCase() }}
    {{ $json.items.length }}
    {{ DateTime.now().toISO() }}

    Pro Tips

    • 💡Think of items as rows in a spreadsheet — each node processes them one by one (unless batching)
    • 💡Binary data is automatically handled when working with file nodes
    • 💡Use $input.first() to get only the first item when you expect a single result

    Comprehension Quiz

    Answer 2 of 2 correctly to unlock lesson completion.

    1. How is data passed between nodes in n8n?

    2. What expression accesses all items from the input?

    Pass the quiz above to unlock lesson completion