Ko-fiSupport
Guides2026-12-02•Last updated: 2026-12-02•7 min read

Converting JSON to CSV and Excel (.xlsx) Without Breaking Encodings, Dates, or Nested Data

B

Brian De Vivar

• Tech Contributor at BrainyTools

Reviewed by Brian De Vivar — software developer & computer science educator with 20+ years of experience building software and teaching networking & systems engineering.

About the Author →
Converting JSON to CSV and Excel (.xlsx) Without Breaking Encodings, Dates, or Nested Data

Every developer and analyst has been there: you pull a clean JSON array from a REST API, convert it to CSV for a stakeholder, and five minutes later they reply with a screenshot showing é instead of é, product SKUs like 00412 stripped to 412, or [object Object] sitting inside every nested column.

Converting hierarchical JSON into flat tabular CSV or Excel (.xlsx) looks trivial on the surface, but real-world production datasets hide subtle edge cases. In this guide, we cover the five most common conversion bugs and show how to convert files cleanly and privately using the JSON to CSV Converter and JSON to Excel Converter.


1. Handling Nested Objects and Arrays Safely

JSON is a tree structure; CSV and Excel worksheets are two-dimensional grids. Consider a typical API response:

[
  {
    "orderId": "ORD-00412",
    "customer": { "name": "Elena Cruz", "region": "APAC" },
    "tags": ["priority", "wholesale"],
    "total": 249.5
  }
]

A naive converter calls .toString() on nested objects, producing useless [object Object] cells. A proper converter applies deterministic dot-notation flattening:

orderId customer.name customer.region tags total
ORD-00412 Elena Cruz APAC ["priority","wholesale"] 249.5

Best practice: When your JSON records are newline-delimited (NDJSON / JSONL from BigQuery, OpenAI batch exports, or server logs), convert them to a standard JSON array first using the JSON / JSONL Converter, then export to CSV or Excel.


2. Fixing Character Encoding & Mojibake (UTF-8 vs. Legacy Encodings)

If accented letters, Japanese/Chinese characters, or currency symbols turn into garbled characters (€, ñ), you are hitting an encoding mismatch:

  • Legacy Exports: Older ERP systems, banks, and regional Windows software often export CSVs in Windows-1252, ISO-8859-1, or Shift-JIS rather than UTF-8. Reading those bytes as UTF-8 corrupts non-ASCII characters.
  • Excel's UTF-8 BOM Quirk: On Windows, double-clicking a plain UTF-8 .csv file causes older versions of Microsoft Excel to assume the local ANSI codepage unless the file begins with a UTF-8 Byte Order Mark (EF BB BF)—or unless you export directly to native .xlsx format, which stores Unicode XML cleanly without ambiguity.

Whenever you upload a CSV or text file into the JSON to CSV Converter or File Splitter, explicitly select the source file's encoding (UTF-8, Windows-1252, ISO-8859-1, Shift-JIS, etc.) so the browser decodes the raw bytes accurately before parsing.


3. Preserving Leading Zeros, Long IDs, and ISO Dates

Microsoft Excel aggressively auto-types values when opening .csv files:

  • Leading zeros vanish: ZIP codes (02138), phone numbers, and SKUs (00412) silently become 2138 and 412.
  • 64-bit integer IDs lose precision: JavaScript and Excel use IEEE 754 double-precision floats (53 bits of integer precision, max 9,007,199,254,740,991). Snowflake IDs or 18-digit transaction IDs get rounded to ...000.
  • Strings turn into dates: Gene names (MARCH1), fractions (10/12), or version labels get coerced into calendar dates.

Fix: Export to native .xlsx using the JSON to Excel Converter whenever string types must remain explicit string cells, or keep IDs quoted as strings in JSON before importing via Excel's Data → From Text/CSV wizard with column types set to Text.


4. Guarding Against CSV Formula Injection

If your JSON includes user-supplied fields (customer notes, display names, support tickets) that start with =, +, -, or @, spreadsheet applications may evaluate the cell as a live formula when opened:

name,comment
"Alice","=HYPERLINK(""https://example.invalid"",""Click here"")"

When sharing CSV exports with non-technical teams, sanitize or prefix untrusted cells that begin with formula trigger characters, and never open untrusted CSV files with external data connections enabled.


CSV vs. Excel (.xlsx) vs. JSONL: Choosing the Right Output Format

Before exporting your dataset, choose the format that matches how the downstream person or system will consume it:

Format Best For Key Advantage Main Limitation
CSV (.csv) Database imports (COPY), Python/Pandas, Git diffs, universal pipelines Plain text, tiny footprint, supported by every tool since the 1970s No native data types (dates, strings, numbers all stored as text); delimiter/encoding quirks
Excel (.xlsx) Finance teams, non-technical stakeholders, multi-sheet reports Preserves explicit text vs. number types, UTF-8 XML strings, and column structure Larger binary ZIP/XML container; 1,048,576 row ceiling per sheet
JSONL / NDJSON (.jsonl) Log streams, BigQuery/Snowflake loads, LLM fine-tuning & batch APIs Streamable line-by-line while preserving full nested objects and arrays Not directly readable in spreadsheet software without conversion

Worked Troubleshooting Guide: 4 Real-World Conversion Failures

Problem 1: Semicolons vs. Commas in European Locales

In many European countries (Germany, France, Spain, Italy), the decimal separator is a comma (12,50), so regional Excel installations expect semicolons (;) as CSV column delimiters. Opening a standard comma-delimited CSV causes every row to collapse into Column A.

  • Solution: Either export directly to native .xlsx using the JSON to Excel Converter (which stores numeric values independently of regional locale) or use Excel's Data → From Text/CSV importer and pick Comma as the delimiter explicitly.

Problem 2: Inconsistent Keys Across JSON Objects (Sparse Schemas)

NoSQL databases (MongoDB, Firestore) and REST APIs often omit null or optional fields on some records:

[
  { "id": 1, "name": "Laptop", "discount": 10 },
  { "id": 2, "name": "Mouse", "warehouse": "US-East" }
]

A naive converter that inspects only the first object to build CSV headers silently drops the warehouse column from row 2! Always use a converter that computes the union of all keys across every record so sparse attributes are preserved as empty cells rather than lost data.

Problem 3: Embedded Newlines and Quotes Breaking Row Counts

Free-text fields like shipping addresses or support comments frequently contain commas, double quotes ("), and line breaks (\n). Under RFC 4180, any cell containing a delimiter, quote, or newline must be wrapped in double quotes, and internal double quotes must be doubled (""). Splitting CSV lines with text.split('\n') breaks immediately on multi-line cells—always rely on a full state-machine parser like PapaParse.

Problem 4: Oversized Files Crashing Browser Tabs or Excel

Trying to open a 300 MB CSV export with 2 million rows in Excel silently truncates everything after row 1,048,576. Before converting or opening massive text exports, split them cleanly along line boundaries—preserving the header row in every chunk—with the Local File Splitter.


5. Processing Sensitive & Oversized Datasets Locally

Customer orders, payroll exports, and CRM dumps should never be pasted into unknown web converters. Both the JSON to CSV Converter and JSON to Excel Converter run PapaParse and SheetJS (xlsx) inside a local browser Web Worker—keeping the UI responsive while guaranteeing zero server uploads.

If your raw export exceeds spreadsheet row limits (1,048,576 rows in Excel) or needs to be chunked into smaller batches for a downstream import tool, break it into clean line-aligned chunks first with the Local File Splitter.


Frequently Asked Questions (FAQ)

Why does Excel show ##### or scientific notation like 1.23E+15 after converting JSON to CSV?

Excel displays ##### simply when a column is too narrow for a formatted number or date (double-click the column divider to auto-fit). Scientific notation (1.23E+15) happens when Excel interprets a long string of digits (like a credit card reference, tracking number, or 18-digit Snowflake ID) as a floating-point number. Exporting to .xlsx preserves string cells explicitly so long IDs are never truncated.

How do I convert JSON back from a CSV file with non-English characters?

Upload the file into the JSON to CSV Converter and select the matching source encoding (UTF-8, Windows-1252, ISO-8859-1, Shift-JIS, or EUC-KR) in the file encoding selector before parsing. If accented characters look garbled in the preview, switch from UTF-8 to Windows-1252 (for Western European exports) or Shift-JIS (for legacy Japanese exports).

Can I convert newline-delimited JSON (JSONL / NDJSON) straight to Excel?

First paste or upload your .jsonl file into the JSON / JSONL Converter to transform it into a standard JSON array, then send that array into the JSON to Excel Converter to download a clean .xlsx workbook locally.

Enjoyed this article?

Check out our suite of free online developer tools to boost your productivity even further. 100% Privacy Focused.

Explore Tools