FormatNest

Data Tools

How to Convert JSON to CSV (and Back) — A Developer Quick Guide

6 min read · Data Conversion · June 2025

JSON and CSV serve different masters. JSON is for APIs and nested data structures. CSV is for spreadsheets, databases, and anything that needs to live in a table. Knowing when and how to convert between them is a core developer skill.

When to use JSON

  • API responses and requests
  • Config files
  • Nested data (objects inside objects)
  • Data that varies in structure between records

When to use CSV

  • Spreadsheets (Excel, Google Sheets)
  • Database imports
  • Reporting and analytics tools
  • Any data that is naturally tabular (same fields in every row)

The key challenge: nested JSON

CSV is flat — every row has the same columns. JSON can be deeply nested. When you convert, you have to decide what to do with nested objects:

  • Flattenuser.address.city becomes a column called user_address_city. Works well for shallow nesting.
  • Stringify — the nested object is serialised as a JSON string in the cell. Good for deep nesting you do not need to query.

How to convert JSON to CSV on FormatNest

  1. Open JSON to CSV.
  2. Paste your JSON or upload a .json file.
  3. Click Convert — FormatNest flattens one level of nesting automatically.
  4. Download the CSV or copy the result.

Converting CSV back to JSON

Use CSV to JSON. The first row is treated as the header (field names). Each subsequent row becomes an object in the JSON array.

Common traps

  • Commas inside values — must be wrapped in double quotes in CSV. FormatNest handles this automatically.
  • Encoding — always save CSV as UTF-8 to avoid character corruption in Excel.
  • Numbers stored as strings — if your JSON has "count": "42" (string, not number), the CSV will carry that through. Check your types.

Data Tools

Try it now — free in your browser

Convert JSON to CSV → ← Back to Blog