Converting CSV to JSON looks trivial: read each row, pair the values with the column names, write out an array of objects. A few lines of code, or a few seconds in an online converter. Yet it is one of the most common places for data to be quietly damaged. ZIP codes lose their first digit, order numbers change, product codes become dates, and nobody notices until a customer record cannot be matched months later.

The damage is rarely caused by JSON itself. It comes from decisions a converter makes on your behalf — usually guessing at types — and from CSV quirks that naive code does not handle. This guide walks through the six most common problems, shows exactly what goes wrong, and explains how to convert safely.

Six examples: 02134 becomes 2134; 9007199254740993 becomes 9007199254740992; 1.50 becomes 1.5; SEPT2 becomes 2-Sep; a quoted name containing a comma is split into extra fields; Zürich becomes garbled when UTF-8 is read as Windows-1252.
Each of these changes happens without an error message. The original value is on the left.

Why CSV values have no type

A CSV file contains only text. The characters 00142 might be a number, a ZIP code or a product ID; the file has no way to say which. JSON, on the other hand, distinguishes between the string "00142" and the number 142.

So every converter must decide: should this value become a JSON string or a JSON number (or boolean, or null)? Converters that “infer types” look at each value and guess. That guessing is the root of the first three problems below.

1. Leading zeros disappear

US ZIP codes in New England start with zero (Boston’s 02134), as do UK phone numbers, many bank sort codes, employee IDs and SKUs. If a converter sees 02134 and decides “that’s a number”, the JSON contains 2134. The zero is gone, and there is no way to know it was ever there.

The fix: treat values as strings by default. Only turn a value into a number when doing so would not change it — and a number with a leading zero always changes. If you need numeric types, apply them column by column, to columns you know are quantities.

2. Long numbers get rounded

JSON allows numbers of any length, but most software that reads JSON — every web browser and Node.js among them — stores numbers as 64-bit floating point. That format represents every integer exactly only up to 9,007,199,254,740,991 (253 − 1). Above that, numbers snap to the nearest value the format can hold:

9007199254740993  →  9007199254740992
12345678901234567890  →  12345678901234567000

This affects order numbers, tracking numbers, database IDs from systems such as Twitter/X (which publish IDs as strings for exactly this reason) and long account numbers. A converter that parses these values as numbers produces JSON that is already wrong, even if the file looks fine.

The fix: keep long digit strings as strings. A safe type-inference rule is “convert only if reading the number back gives the identical text” — which rejects anything longer than about 15–16 significant digits.

3. Formatting inside numbers is lost

Even small numbers can change. 1.50 becomes 1.5, 2.10 (a software version) becomes 2.1, 1e3 becomes 1000, and +44 becomes 44. For a price these may be harmless; for a version number, a measurement with stated precision or an international dialling code they are not.

The fix: the same round-trip rule. If the JSON number would print differently from the CSV text, keep it as a string.

4. Text becomes dates (usually in a spreadsheet)

This one happens before the conversion, when a CSV is opened and re-saved in a spreadsheet. Excel and other spreadsheet apps convert anything that looks like a date: 1-2 becomes 2 January, MARCH1 and SEPT2 become dates, and long numbers are displayed in scientific notation and truncated to 15 significant digits.

The problem is serious enough to have changed science. A 2016 study in Genome Biology found gene-name errors caused by spreadsheet autoconversion in roughly one in five papers with supplementary gene lists. In 2020 the HUGO Gene Nomenclature Committee renamed 27 human genes — SEPT1 became SEPTIN1, MARCH1 became MARCHF1 — partly to stop spreadsheets mangling them.

The fix: do not round-trip data through a spreadsheet before converting. Convert the original CSV directly. If someone must edit it in Excel, import it with Data → From Text/CSV and set sensitive columns to Text, rather than double-clicking the file.

5. Quoted commas and line breaks split fields

A correctly written CSV wraps values that contain commas in double quotes: "Lee, Morgan". Code that simply splits each line on commas reads that as two fields, and every column after it shifts one place to the right. Values containing line breaks — common in addresses and notes — are split into separate rows. Escaped quotes ("" inside a quoted field) also trip up home-made parsers.

The fix: use a real CSV parser that follows RFC 4180 quoting rules, and check the parsed table before trusting the output. A good converter shows you the rows it found, so a shifted column is obvious at a glance.

6. Characters are garbled by the wrong encoding

If a UTF-8 file is read as Windows-1252, Zürich becomes Zürich and € becomes €. If a Windows-1252 file is read as UTF-8, accented characters may be replaced with � or rejected. Excel’s classic “CSV” export uses a legacy encoding on many systems, while “CSV UTF-8” adds a byte order mark (BOM) — three invisible bytes at the start of the file.

The fix: know your file’s encoding. A careful converter detects the BOM and removes it (it is not part of the data), refuses invalid UTF-8 instead of silently substituting characters, and lets you choose an alternative encoding explicitly.

Two structural problems to watch

Besides value changes, two structural issues cause trouble:

  • Duplicate or blank column names. JSON object keys must be unique. If a CSV has two email columns, a converter that builds objects will silently keep only one. A safe converter stops and asks — for example, renaming the second to email_2 — rather than dropping data.
  • Rows with the wrong number of fields. A row with fewer values than the header is often a sign of a wrong delimiter or a broken quote. Decide explicitly whether to keep such rows (with missing values as null) or skip them, and look at a few before you choose.

A safe conversion checklist

  1. Start from the original CSV, not a copy re-saved by a spreadsheet.
  2. Check the delimiter. Comma, semicolon and tab are all common. Look at the parsed preview to confirm columns line up.
  3. Check the header row. Make sure every column has a unique, non-blank name.
  4. Keep values as strings unless you need numbers, and then only infer types that round-trip exactly.
  5. Decide how to handle uneven rows rather than letting the tool decide silently.
  6. Spot-check the output. Find a row with a leading-zero ID, a long number and a comma-containing value, and confirm they survived.
  7. Validate the JSON before handing it on — a JSON formatter and validator confirms the file parses and shows its structure.

Converting with RapidConvertor

The CSV to JSON converter was built around these rules. It parses with a standards-compliant CSV parser, keeps every value as a string by default, and offers type inference that only converts values which read back identically — so 00142, 1.50 and 12345678901234567890 stay as written while 42 and 0.1 become numbers. It asks before renaming duplicate headers or handling uneven rows, reports unterminated quotes with the row and line number, removes the BOM and tells you it did, and runs entirely in your browser, so the data never leaves your device.

If the CSV needs tidying first — stray spaces, blank lines or duplicate rows — run it through the CSV Cleaner, which shows every change before you download.

Summary

Conversions lose data when a tool guesses. Leading zeros, long numbers and number formatting are lost to over-eager type inference; dates appear when a spreadsheet touches the file; quoted values split when the parser is naive; and characters garble when the encoding is wrong. Keep values as text unless you are certain, use a real parser, check the preview, and you will get JSON that says exactly what the CSV said.