Handling messy API JSON in n8n workflows?

I’ve been building workflows in n8n and keep running into the same issue:

APIs return messy or inconsistent JSON, and it becomes painful to:

  • flatten nested data
  • normalize fields
  • handle missing/null values

I end up writing a lot of Function nodes just to clean things up.

Example:

Input:
{
“user”: {
“name”: “John”,
“email”: null
},
“orders”: [{ “total”: “29.99” }]
}

What I actually want:
{
“name”: “John”,
“email”: “”,
“order_total”: 29.99
}

I got tired of doing this manually, so I built a small JSON pipeline tool that handles this kind of transformation automatically (flattening, type normalization, cleanup).

It produces clean, predictable output before passing data to the next node.

Curious how others are solving this in n8n—are you relying on Function nodes, or is there a better pattern?

If anyone wants to try what I built:

Learning JMESPath is a super power for handling json in n8n.
It’s available for expressions via the$jmespath function.

{{
$jmespath($json,`{
  name: user.name,
  email: user.email || '',
  order_total: orders[0].total
}`)
}}
2 Likes