You've pulled data from an API and it comes back as JSON. Your client wants a spreadsheet. Or you have a CSV export from a database and need to feed it into a JavaScript app expecting an array of objects. Either way, the conversion is straightforward conceptually but tedious to do by hand, and writing a throwaway script every time isn't much better.
This guide explains what happens structurally when you convert between JSON and CSV, where things go wrong, and how to do it instantly in your browser using the free tools on DevToolShack.
What JSON and CSV Actually Are
JSON (JavaScript Object Notation) is a text format for representing structured data as nested objects and arrays. It handles strings, numbers, booleans, nulls, arrays, and objects, including objects nested inside objects. It's the native format for most modern web APIs.
CSV (Comma-Separated Values) is a flat tabular format. Every row is a record, every column is a field, and the first row is typically a header. There's no standard for nested data, no native support for arrays within a cell, and no concept of types. Everything is a string unless something else interprets it.
That structural mismatch is the source of most conversion problems.
Converting JSON to CSV
JSON converts cleanly to CSV when the JSON is a flat array of objects where every object has the same keys. This structure maps perfectly to a table: the keys become column headers, each object becomes a row.
[
{ "name": "Alice", "role": "Engineer", "team": "Platform" },
{ "name": "Bob", "role": "Designer", "team": "Product" },
{ "name": "Carol", "role": "Engineer", "team": "Platform" }
]
That JSON produces this CSV:
name,role,team
Alice,Engineer,Platform
Bob,Designer,Product
Carol,Engineer,Platform
Use the JSON to CSV converter on DevToolShack to paste in any array of objects and get a downloadable CSV in seconds — no sign-up, no upload, nothing leaves your browser.
When JSON Doesn't Convert Cleanly
Nested objects are the most common problem. If your JSON looks like this:
[
{ "name": "Alice", "address": { "city": "Austin", "state": "TX" } }
]
There's no clean way to represent the nested address object in a flat CSV. Converters handle this in a few ways: flattening the keys (producing columns named address.city and address.state), serializing the nested object as a JSON string in a single cell, or dropping the nested data entirely. Know which approach your converter uses before you rely on the output.
Arrays within objects have the same problem. A field like "tags": ["javascript", "api"] doesn't have a natural CSV representation. Some converters join the values with a separator; others drop them.
Missing and Inconsistent Keys
If your objects don't all have the same keys, the converter has to decide what to put in the empty cells. Most use an empty string or blank cell. If you're feeding the CSV into something that cares about data types, watch for empty cells being interpreted as zeros or nulls unexpectedly.
Values Containing Commas or Quotes
CSV uses commas as delimiters, so any value that contains a comma must be wrapped in double quotes. Values containing double quotes need those quotes escaped by doubling them. A proper CSV converter handles this automatically, but if you're generating CSV manually in code, it's easy to forget and produce broken output that tools like Excel will mangle.
Converting CSV to JSON
The reverse conversion is usually cleaner because CSV is simpler: it's already tabular, and tabular data maps directly to an array of objects. The CSV to JSON converter on DevToolShack handles this automatically, treating the first row as keys and each subsequent row as an object.
The input CSV:
id,name,score
1,Alice,94
2,Bob,87
3,Carol,91
Produces this JSON:
[
{ "id": "1", "name": "Alice", "score": "94" },
{ "id": "2", "name": "Bob", "score": "87" },
{ "id": "3", "name": "Carol", "score": "91" }
]
The Type Problem
Notice that id and score came out as strings, not numbers. CSV has no type system; everything is text. A converter can try to infer types (if a value looks like a number, treat it as one), but that inference can go wrong. The value "007" should stay a string; the value 94 should probably be a number. Most converters offer an option for type inference; use it with care and check the output.
This is especially relevant when you're feeding the JSON into an API or database that has strict type requirements. If your downstream code does score + 1 and gets "941" instead of 95, you've got a type coercion bug from the conversion.
Headers with Special Characters
CSV headers become JSON object keys. If your CSV has a header like First Name (with a space) or Q1 Revenue ($) (with special characters), those become the keys in your JSON objects. That's valid JSON, but accessing those keys in JavaScript requires bracket notation: row["First Name"] rather than row.firstName. If your downstream code expects camelCase keys, you'll need to do a rename pass after conversion.
Working with Large Files
Browser-based converters work entirely in memory. For truly large files (tens of megabytes or more), you'll hit browser limits. For one-off conversions of modest files, the browser tools are faster than setting up a script. For regular automated conversions of large datasets, a server-side approach using Python's csv and json modules, or Node's streaming CSV parsers, will be more reliable.
For quick data inspection before converting, the CSV Table Viewer lets you paste in any CSV and see it rendered as a proper table — useful for checking that your CSV is well-formed before you hand it to a converter.
JSON to XML and Other Formats
If your target isn't CSV but XML, DevToolShack also has a JSON to XML converter. The structural considerations are similar: flat JSON converts cleanly; deeply nested JSON requires decisions about how to represent arrays in XML's element model. For a full comparison of when JSON, CSV, and XML each make sense, see JSON vs CSV vs XML: Which Data Format Should You Use?
Viewing and Formatting Your JSON
If you're working with API responses and the JSON arrives as a single line of minified text, the JSON Formatter will pretty-print it with proper indentation so you can see the structure before converting. This is especially useful for spotting nested objects or arrays that might cause problems in the CSV output. You can also use the JSON Path Tester to query specific fields out of complex JSON before converting, if you only need a subset of the data.