Here's a secret that experienced automation builders know:
Most workflow complexity isn't in the logic. It's in the data transformation.
The trigger fires correctly. The API calls work. But the data arrives in one format and needs to be in another format, and bridging that gap is where everyone gets stuck.
Master data transformation, and everything else gets easier.
Why Data Transformation Matters
Every system has opinions about data:
- Stripe wants amounts in cents:
9900 - Your CRM wants dollars:
$99.00 - The API returns dates as:
2026-01-15T00:00:00Z - Your spreadsheet wants:
01/15/2026 - The webhook sends:
{customer: {name: "John"}} - Your database wants:
{customer_name: "John"}
Your job is to translate between these opinions. That's data transformation.
The Core Operations
All data transformation boils down to a few operations:
1. Rename Fields
The simplest transformation. Source says firstName, destination wants first_name.
Before:
```json
{ "firstName": "John", "lastName": "Doe" }
```
After:
```json
{ "first_name": "John", "last_name": "Doe" }
```
2. Restructure Objects
Flatten nested data or nest flat data.
Flatten:
```json
// Before
{ "customer": { "email": "john@example.com" } }
// After
{ "customer_email": "john@example.com" }
```
Nest:
```json
// Before
{ "billing_city": "NYC", "billing_country": "US" }
// After
{ "billing_address": { "city": "NYC", "country": "US" } }
```
3. Convert Types
Strings to numbers, numbers to strings, dates to different formats.
Examples:
"42"→42(string to number)9900→"$99.00"(cents to formatted currency)"2026-01-15T00:00:00Z"→"Jan 15, 2026"(ISO to readable)
4. Filter Arrays
Select only items that match certain criteria.
Before:
```json
[
{ "status": "active", "name": "John" },
{ "status": "inactive", "name": "Jane" },
{ "status": "active", "name": "Bob" }
]
```
After (keep active only):
```json
[
{ "status": "active", "name": "John" },
{ "status": "active", "name": "Bob" }
]
```
5. Map Arrays
Transform each item in an array.
Before:
```json
[
{ "firstName": "John", "lastName": "Doe" },
{ "firstName": "Jane", "lastName": "Smith" }
]
```
After (combine names):
```json
[
{ "fullName": "John Doe" },
{ "fullName": "Jane Smith" }
]
```
6. Aggregate
Combine multiple items into summary data.
Before:
```json
[
{ "amount": 100 },
{ "amount": 200 },
{ "amount": 150 }
]
```
After (sum):
```json
{ "totalAmount": 450, "count": 3, "average": 150 }
```
7. Split
Turn one item into many.
Before:
```json
{ "tags": "marketing,sales,urgent" }
```
After:
```json
[
{ "tag": "marketing" },
{ "tag": "sales" },
{ "tag": "urgent" }
]
```
8. Merge
Combine data from multiple sources.
Source 1:
```json
{ "id": 123, "name": "John" }
```
Source 2:
```json
{ "id": 123, "email": "john@example.com" }
```
After:
```json
{ "id": 123, "name": "John", "email": "john@example.com" }
```
Transformation in n8n
n8n has several nodes for transformation:
Set Node
Add, remove, or rename fields. Good for simple transformations.
Function/Code Node
Write JavaScript for complex transformations. Maximum flexibility.
Item Lists Node
Work with arrays — split, merge, aggregate, sort.
Date & Time Node
Parse, format, and calculate dates.
Expressions
Inline transformations using the expression editor: {{ $json.price / 100 }}
Practical Transformation Patterns
Pattern 1: Webhook to CRM
Incoming webhook data:
```json
{
"form_data": {
"name": "John Doe",
"email": "john@example.com",
"company_size": "50-100"
}
}
```
CRM API expects:
```json
{
"properties": {
"firstname": "John",
"lastname": "Doe",
"email": "john@example.com",
"company_size": "medium"
}
}
```
Transformations needed:
- Split "name" into "firstname" and "lastname"
- Map "50-100" to "medium"
- Restructure into "properties" object
Pattern 2: API to Spreadsheet
API response:
```json
{
"data": [
{ "id": 1, "attributes": { "created": "2026-01-15T14:30:00Z", "total_cents": 9900 } }
]
}
```
Spreadsheet needs:
- Date: "01/15/2026"
- Time: "2:30 PM"
- Total: "$99.00"
Transformations needed:
- Extract from nested structure
- Format date and time
- Convert cents to dollars with formatting
Pattern 3: Multi-Source Merge
From CRM:
```json
{ "email": "john@example.com", "lead_score": 85 }
```
From Email Platform:
```json
{ "email": "john@example.com", "opens": 12, "clicks": 3 }
```
Combined result:
```json
{
"email": "john@example.com",
"lead_score": 85,
"engagement": { "opens": 12, "clicks": 3, "click_rate": 0.25 }
}
```
Debugging Transformations
When transformations don't work:
Check the Input
What does the data actually look like? Use n8n's execution view to see real data, not what you expected.
Check the Types
Is it a string that looks like a number? An array with one item vs the item itself? Type mismatches cause many issues.
Go Step by Step
Don't transform everything at once. Do one transformation, verify, then the next.
Handle Missing Data
What if a field doesn't exist? Use defaults and null checks.
The Transformation Mindset
Here's how to think about data transformation:
Input and output are contracts. Know exactly what you're receiving and what you need to produce.
Test with real data. Sample data often doesn't reveal edge cases.
Transformations are code. Even in no-code tools, you're expressing logic. Think about it rigorously.
Document your transformations. Future you will forget why you did that weird mapping.
Master this skill, and integrations that seemed impossible become straightforward.
Want to practice data transformation? Nodox.ai challenges involve real data transformation problems — the skill that makes all automation easier.