How to Convert JSON to CSV Without Losing Rows

JSON is how APIs talk. CSV is how spreadsheets, finance teams, and a lot of internal tools still eat data. The conversion looks trivial until a nested object becomes [object Object], a comma inside a company name splits a column, or half the rows vanish because one record missed a key.

A JSON to CSV converter is a translator between a tree and a table. Nicxro’s converter should make that translation visible, not magical. This is how to do it without lying to Excel.

Tables are flat. JSON often is not.

CSV is rows and columns. Every row has the same column names, in practice, even if some cells are empty.

JSON can be an array of objects. That maps well. It can also be an object with nested arrays, or an array of arrays, or a mix where item 0 has email and item 1 has profile.email.

If you convert nested JSON blindly, you get one of three bad outcomes: flattened keys like profile.email, stringified blobs in a cell, or dropped fields.

Before you convert, look at the JSON in a formatter. If it is not an array of similar objects, do not expect a pretty spreadsheet. You may need to pick a path, such as data.users, and convert that array only.

Start by formatting and validating

Invalid JSON will not convert. Trailing commas, single quotes, and HTML error pages will fail. Use Nicxro’s JSON formatter first. When it pretty-prints, you have a document. Then convert.

If the payload is huge, convert a slice of two records first. Confirm columns. Then convert the full file. Debugging 50,000 messy rows in Excel is how afternoons disappear.

Choose a flattening rule and stick to it

Nested object:

{
  "id": 1,
  "name": "Ada",
  "address": { "city": "Lisbon", "zip": "1000" }
}

Reasonable CSV columns: id, name, address.city, address.zip.

Nested array of strings: tags: ["a","b"]. Options: join with a pipe a|b, duplicate rows, or JSON-in-cell ["a","b"]. Joining is readable. Duplicating rows is correct for some analyses and confusing for others. JSON-in-cell is honest and ugly in Excel.

Array of objects, such as orders, usually should not flatten into one row per user unless you want a nested dump. Export orders as their own CSV with a user_id column. Two tables beat one denormalized monster if the nest is deep.

Nicxro may pick a default. Read a few output rows. If you see empty columns with dotted names, that is flattening. If you see quoted JSON in a cell, that is a nest the tool would not flatten. Decide if that is acceptable.

Commas, quotes, and newlines in fields

CSV is not “split on comma.” Fields that contain commas must be quoted. Fields that contain quotes must escape quotes by doubling them. Fields that contain newlines are legal in CSV and painful in tools that assume one row per line.

If a converter does not quote correctly, Excel will shift columns. Company names like Smith, Jones & Co are the usual victim.

When you open the file, use Excel’s import wizard or Google Sheets import if columns look wrong. Do not assume double-click is a parser. UTF-8 with BOM can help Excel not destroy accented characters. If names look like Café, the encoding is wrong. Re-export as UTF-8. In Excel, Data > From Text, and set UTF-8.

Types become strings whether you like it or not

CSV has no types. true is a string. 00123 will become 123 in Excel if it thinks the column is a number. IDs, zip codes, phone numbers, and leading zeros need a hint. Some teams prefix with a tab or wrap as ="00123" for Excel. Others import as text.

ISO dates can become US dates and shift by one day because of timezones. If the original JSON had "2026-08-20", keep that string. If Excel turns it into a serial, you may have a locale problem.

null vs missing key vs empty string: pick a representation. Empty cell is fine. The word null in a cell will confuse a pivot table. Be consistent.

Rows that disappear

If the converter uses the keys of the first object as columns, later objects with extra keys lose those extra keys. If it unions all keys, you get sparse columns. Union is usually what you want for exports.

If a record is a nested array and the converter expected objects, it may skip it. Format the JSON and look for an item that is a different shape. Homogenize in code, or filter the array.

Empty array input should produce a header-only CSV or an empty file. Know which one your tool does. Downstream jobs may break on “no header.”

Excel-specific traps

Sheets have row limits. A JSON file that converts to a million rows will not fit. Split.

The first eight rows of a column decide type in some Excel versions. A column of IDs that starts with numeric-looking values will eat later text. Import as text.

SEP=, tricks and regional settings: some locales use ; as the delimiter. If your CSV is comma-separated and Excel expects semicolon, everything lands in column A. Tell the import the delimiter, or export ; if that is your audience.

Formulas: a cell that starts with = can become a formula. That is a security nuisance in untrusted CSV. Prefix with a quote or space if you export untrusted data to people who will open it in Excel.

A practical conversion path

  1. Validate JSON.
  2. Identify the array of records. Extract it if it sits under data.
  3. Convert two records. Check columns.
  4. Convert all. Spot-check a row that had nested data, a row with commas in text, and a row with Unicode.
  5. Open in a spreadsheet with UTF-8 and explicit delimiter.
  6. Only then send it to finance.

If you do this every day, write a script. Nicxro is for the one-off, the partner file, the “can you just give me this in Excel” Slack message.

JSON Lines and mixed dumps

Logs may be NDJSON: one JSON object per line, not one array. A converter that expects [...] will fail. Wrap as an array, or convert line by line. Do not search-replace blindly and produce invalid JSON.

If the file is JSON inside CSV already, you are in a hole. Parse with a real CSV parser, then parse the JSON cell. A second JSON-to-CSV pass on that cell may be what you need.

Keep the original

The CSV is a view. The JSON is the source. If someone edits the spreadsheet and you convert back, types and nests will not return perfectly. Round-tripping JSON to CSV to JSON is lossy in the general case. Do not use CSV as your system of record for nested APIs.

When the spreadsheet is the deliverable, convert carefully, name the file with a date, and keep the JSON next to it. When they ask why a field is missing, you can show the record.

Nicxro’s converter saves you from writing a one-off script at 6 p.m. Your eyes still have to confirm that the table matches the tree. Format first, flatten on purpose, quote fields, and open the CSV like it might betray you. That skepticism is what keeps rows from disappearing on the way to Excel.

Leave a Comment