Conversion Rules That Work
- Flatten nested keys using dot-path columns (example:
user.profile.age). - Decide array strategy: explode rows vs joined cell values.
- Normalize missing keys as blank/null for consistent headers.
Example
// Input JSON
{
"user": { "id": 7, "name": "Ava" },
"tags": ["admin", "editor"]
}
// CSV headers
user.id,user.name,tagsWorkflow
- Validate and format input first.
- Run JSON to CSV.
- Round-trip check with CSV to JSON for data loss detection.
- Use JSON Diff between source and rehydrated output.
Common Pitfalls
- Arrays of objects that should become multiple rows but are collapsed into a cell.
- Nested keys that disappear because headers are inferred from the first row only.
- Inconsistent types between rows (string vs number).
FAQ
Should I flatten all nested objects?
Flatten only the parts required by downstream tools. Deep flattening can make CSV hard to work with.
How do I preserve arrays?
Either explode arrays into multiple rows or join with a delimiter; pick one and stay consistent.