Tools mentioned in this article
Open the browser-based tool while you read and try the workflow immediately.
CSV and JSON solve different problems
CSV is simple, tabular, and easy to open in spreadsheet tools.
JSON is better for structured data such as API responses, configuration, arrays, and nested objects.

Being able to convert between them helps with handoffs between teams, bulk imports, admin tools, API testing, and data cleanup.
Converting CSV to JSON
Use the header row as keys
Most CSV files start with headers like name,email,role.
When converting to JSON, those headers usually become object keys.
[
{ "name": "Alice", "email": "alice@example.com", "role": "admin" }
]
Check the delimiter
Not every CSV-like file is comma-separated.
Some exports use tabs or semicolons, especially when data comes from spreadsheets or regional settings.
If the columns do not split correctly, the delimiter is the first thing to check.
Be careful with value types
CSV values often arrive as plain text.
After converting to JSON, confirm whether values such as IDs, postal codes, and phone numbers should remain strings even when they look numeric.
Converting JSON to CSV
JSON converts cleanly to CSV when it is an array of objects with similar keys.
Nested objects and arrays need an extra decision: flatten them into keys such as profile.name, serialize them into a cell, or omit fields that are not useful in a table.
For spreadsheets and imports, a small, predictable set of columns is usually easier to maintain than a perfect copy of the whole JSON structure.
Example: Turning an array of objects into CSV
Given JSON like this,
[
{ "id": 1, "name": "Alice", "role": "admin" },
{ "id": 2, "name": "Bob", "role": "member" }
]
if every object has the same keys, you only need to map the keys to the header row and the values to each row to get CSV.
id,name,role
1,Alice,admin
2,Bob,member
Conversely, if the keys differ from object to object (for example, one has no role), the columns shift. Checking beforehand that every record has the same shape prevents accidents.
Pitfalls with escaping and character encoding
CSV looks simple, which also makes it easy to break depending on the values. Two things commonly trip people up in practice.
Values containing commas, line breaks or quotes
If a value itself contains a comma or a line break, the columns shift unless you escape it by wrapping it in quotes. RFC 4180 says to wrap the value in "..." and double any " inside it as "".
id,note
1,"Hello, world"
2,"A note
over two lines"
3,"He said ""OK"""
Check whether your conversion tool or library does this escaping automatically. If you join strings by hand, you will almost certainly fall into this trap.
Character encoding and the BOM
Opening a CSV that contains Japanese in Excel can show garbled text. This happens because Excel mistakes UTF-8 for Shift_JIS, and saving as UTF-8 with BOM lets it open correctly in many environments. Conversely, a program that reads the file may need to strip the BOM or the first key will be off, so choose according to the use.
Use DevToolKits for conversion
The CSV ⇔ JSON converter supports both directions and lets you choose delimiters and header handling.
After conversion, use the JSON formatter to inspect the output, or the JSON ⇔ YAML converter when the data needs to become configuration.
Frequently Asked Questions
CSV numbers turn into numeric values in JSON—how do I keep them as strings?
Values like postal codes, IDs, and phone numbers that “look numeric but should be strings” can lose leading zeros or overflow if converted to numbers. Use a “treat as string” option during conversion if available, or check and fix the type of those fields after converting.
Can I convert nested JSON to CSV?
CSV is a flat, tabular format, so nested objects and arrays don’t fit in a single cell as-is. Flatten keys like profile.name, or narrow down to just the fields you need before converting to CSV.
My columns are misaligned even though it’s comma-separated.
If a value contains a comma or newline, columns will shift unless it’s properly escaped with surrounding quotes ("..."). Also, a file called “CSV” may actually be tab- or semicolon-separated. Check the delimiter and quoting settings.
Japanese text is garbled when I open the file in Excel.
Excel can mistake UTF-8 CSV for Shift_JIS, which garbles Japanese text. Saving again as UTF-8 with BOM displays it correctly in many environments. Conversely, when you read the file from a program, the BOM can slip in as an extra character, so strip it on the reading side.
Can I turn JSON with inconsistent keys into CSV?
When keys differ between records, you can combine them into one CSV by using the union of all keys as the header and leaving missing values empty. The columns multiply and it becomes hard to see, though, so we recommend either making the shape of the data consistent beforehand or narrowing to the fields you need.
