n8n Basics: How to Parse Any JSON Data — Step by Step
If you're building automation workflows, you'll encounter JSON data almost everywhere — from API responses to webhook payloads and database outputs. Knowing how to correctly parse and work with JSON is one of the most essential skills in n8n. In this guide, we'll walk you through everything you need to know, step by step.
What Is JSON and Why Does It Matter in Automation?
JSON (JavaScript Object Notation) is a lightweight data format used to transmit information between systems. It structures data as key-value pairs and supports nested objects and arrays. When you connect different apps and services inside n8n, most of them communicate using JSON.
Understanding how to read, access, and transform JSON data allows you to:
- Extract specific fields from API responses
- Pass the right values between workflow nodes
- Filter and transform data on the fly
- Avoid errors caused by mismatched data structures
Step 1: Receive JSON Data in Your Workflow
The first step is getting JSON into your n8n workflow. The most common ways to receive JSON data are:
- Webhook Node: Receive real-time POST requests from external services
- HTTP Request Node: Fetch data from any REST API
- Trigger Nodes: Apps like Slack, Airtable, or Google Sheets send structured JSON automatically
Once your trigger fires, n8n automatically stores the incoming JSON in the node's output. You can inspect it by clicking on the node output panel on the right side of the canvas.
Step 2: Understand the n8n Data Structure
n8n wraps all data in its own internal format. Each item in a node's output looks like this:
- json: The actual data object containing your key-value pairs
- binary: Optional binary data (files, images)
So if your API returns { "name": "Alice", "age": 30 }, inside n8n it will be accessible as {{ $json.name }} and {{ $json.age }}.
Step 3: Access JSON Fields Using Expressions
n8n uses a powerful expression engine to let you reference JSON data dynamically. You can activate expressions in almost any field by clicking the = icon next to it.
Here are the most common expression patterns:
- {{ $json.fieldName }} — Access a top-level field
- {{ $json.user.email }} — Access a nested field
- {{ $json.items[0].title }} — Access the first element of an array
- {{ $json["field-with-dashes"] }} — Access fields with special characters
These expressions make n8n incredibly flexible when dealing with complex, deeply nested JSON structures.
Step 4: Parse and Transform JSON with the Code Node
For advanced use cases, the Code Node in n8n lets you write custom JavaScript to parse and reshape any JSON structure. This is especially useful when:
- You need to loop through large arrays
- You want to merge multiple fields into one
- You need conditional logic based on JSON values
A simple example inside the Code Node:
- Input: items array from a previous node
- Logic: Filter items where status === "active"
- Output: A clean array of only active items passed to the next node
The n8n Code Node supports full ES6+ JavaScript, giving you complete control over your data transformation logic.
Step 5: Use the Set Node to Clean Up Your Data
Once you've accessed the JSON fields you need, the Set Node in n8n is the perfect tool to reshape your data. Use it to:
- Keep only the fields you actually need
- Rename fields to match the next service's expectations
- Add static values or calculated fields
This ensures your downstream nodes always receive clean, predictable data — a key principle in building robust n8n workflows.
Step 6: Handle Arrays with the Split In Batches or Item Lists Node
JSON often contains arrays of objects — for example, a list of orders, users, or products. In n8n, you can process these arrays efficiently using:
- Split In Batches Node: Process large arrays in chunks to avoid timeouts
- Item Lists Node: Split an array field into separate individual items for per-row processing
This is one of the most powerful patterns in n8n for handling bulk data from APIs or databases.
Common JSON Parsing Errors and How to Fix Them
Even experienced users run into JSON issues. Here are the most common problems in n8n and their solutions:
- Undefined field: Double-check the exact key name — JSON is case-sensitive
- Cannot read property of null: Add a check with {{ $json.field ?? 'default' }}
- Array not iterable: Use the Item Lists Node to convert the array into separate items
- Unexpected token: Make sure the incoming data is valid JSON — use a validator tool first
Pro Tips for Working with JSON in n8n
- Always use the Output Panel in n8n to inspect real data before writing expressions
- Use JSON.parse() in the Code Node if a field contains a JSON string instead of an object
- Name your nodes clearly so you can reference previous nodes with {{ $node["NodeName"].json.field }}
- Test with small payloads first, then scale up your n8n workflow
Conclusion
Parsing JSON in n8n doesn't have to be complicated. Once you understand the data structure, expressions, and the right nodes to use, you can handle virtually any JSON payload with confidence. Start building smarter automations with n8n today — and let your data flow exactly where it needs to go.
This post was created with tools we use and recommend: n8n for workflow automation, Turbotic as an AI-native automation alternative, ElevenLabs for AI voiceover, Placid for visual content creation, and Hostinger for reliable VPS hosting. Some links are affiliate links.