When You Need JSON to CSV Conversion§

JSON is the standard format for APIs and modern data exchange. CSV is what every spreadsheet tool, data analyst, and business stakeholder expects. The gap between them is a constant friction point in data work.

Common scenarios:

  • You hit a REST API and got JSON back — but your client wants an Excel spreadsheet
  • A developer gave you a database export in JSON — but you need to import it into a data warehouse
  • You built a web scraper that outputs JSON — but your analysis tool is Python pandas or R, which load CSV natively
  • You queried a NoSQL database (MongoDB, Firestore) and need to flatten the results for a SQL import

The NexaTools JSON to CSV Converter handles flat and nested JSON, arrays of objects, and edge cases — entirely in your browser.


The Basic Conversion: Flat JSON§

The simplest case is an array of flat objects where every object has the same keys:

[
 {"id": 1, "name": "Alice", "role": "Engineer", "active": true},
 {"id": 2, "name": "Bob", "role": "Designer", "active": false},
 {"id": 3, "name": "Carol", "role": "Manager", "active": true}
]

This converts directly to CSV:

id,name,role,active
1,Alice,Engineer,true
2,Bob,Designer,false
3,Carol,Manager,true

Each JSON object becomes a row. Each key becomes a column header. Clean and straightforward.


The Real Challenge: Nested JSON§

Real-world API responses are rarely flat. Nested objects create the conversion challenge:

[
 {
 "id": 1,
 "user": {
 "name": "Alice",
 "email": "alice@example.com"
 },
 "order": {
 "total": 149.99,
 "items": 3
 }
 }
]

There are two strategies for handling nesting:

Dot notation flattening§

Nested keys are joined with a dot to create column headers:

id,user.name,user.email,order.total,order.items
1,Alice,alice@example.com,149.99,3

This preserves all data and is readable, but column headers become long. Most spreadsheet tools handle this fine.

Full flattening§

Similar to dot notation but uses underscores: user_name, user_email. Preferred when column headers will become database column names (dots are invalid in most SQL identifiers).

The NexaTools converter supports both approaches, selectable before conversion.


Arrays Within Objects§

Arrays inside JSON objects are the hardest case to handle gracefully:

[
 {
 "id": 1,
 "name": "Alice",
 "skills": ["Python", "SQL", "JavaScript"]
 }
]

There is no perfect CSV representation for an array nested inside a row. The converter offers two options:

Option 1: Join as a delimited string

id,name,skills
1,Alice,"Python|SQL|JavaScript"

Simple, preserves in one row, but requires splitting later.

Option 2: Expand to multiple rows

id,name,skills
1,Alice,Python
1,Alice,SQL
1,Alice,JavaScript

The row is duplicated for each array item. Useful for analysis (each skill is its own row), but duplicates other fields.

Choose based on your downstream use case.


How to Convert on NexaTools§

  1. Open the tool: Visit JSON to CSV
  2. Paste or upload your JSON: Paste directly or load a .json file — no upload to server
  3. Choose options:
  • Nesting separator (. or _)
  • Array handling (join or expand)
  • Include/exclude specific keys
  1. Preview the output: See the first rows of the CSV before downloading
  2. Download: Get the .csv file

Large files process in a Web Worker to keep the UI responsive.


Edge Cases and How They're Handled§

Missing keys§

If some objects in your array don't have a key that others do, the converter adds an empty cell for that row rather than failing:

[
 {"id": 1, "name": "Alice", "phone": "555-1234"},
 {"id": 2, "name": "Bob"}
]
id,name,phone
1,Alice,555-1234
2,Bob,

Values containing commas§

If a value contains a comma, it must be wrapped in double quotes in the CSV:

1,"Smith, Alice",Engineer

The converter handles this automatically.

Values containing double quotes§

A double quote inside a quoted CSV field must be escaped by doubling it:

1,"He said ""hello""",Engineer

This is the RFC 4180 standard for CSV. The converter follows it correctly.

Null values§

JSON null → empty cell in CSV. The converter distinguishes between null (empty cell) and "" (empty string with quotes).

Boolean and number types§

JSON booleans (true/false) and numbers are output without quotes in CSV, preserving their type hint for tools that infer column types on import.


What to Do With the CSV§

Import into Excel or Google Sheets§

Both handle CSV import with column type detection. For UTF-8 data (non-ASCII characters), use "Import" rather than just opening the file in Excel to ensure correct encoding.

Load into Python pandas§

import pandas as pd
df = pd.read_csv('output.csv')
print(df.head())

Import into a SQL database§

COPY users FROM '/path/to/output.csv'
DELIMITER ',' CSV HEADER;

(PostgreSQL syntax; MySQL and SQLite have similar commands)

Use in Tableau, Power BI, or Looker§

All major BI tools accept CSV as a data source.


The Reverse: CSV to JSON§

If you need to go the other direction — turning a spreadsheet or CSV export into JSON for an API or NoSQL import — use the CSV to JSON converter.



Convert any JSON to CSV instantly with NexaTools JSON to CSV — handles nested objects, arrays, and edge cases. Free, no upload.