MiniUtil field guide

How to Convert CSV to JSON Without Losing Data

Convert CSV to JSON while preserving quoted fields, leading zeroes, dates, empty values, encodings, and a predictable object structure.

Short answer: Parse the CSV with its real delimiter and quoting rules, keep ambiguous values as strings, clean the table, then validate the generated JSON.

Inspect the table before converting it

Confirm the delimiter, header row, encoding, and number of fields per record. Do not split lines on commas manually: quoted fields can contain commas, line breaks, and doubled quote characters.

  • Keep an unchanged copy of the source file.
  • Check a row containing punctuation and non-ASCII text.
  • Confirm headers are unique and non-empty.

Decide which values must remain strings

CSV does not carry a universal schema. A value that looks numeric may be an identifier, ZIP code, account number, or product code. Preserve leading zeroes and long integers as strings unless the destination explicitly defines them as numbers.

Clean columns and duplicates first

Remove unwanted columns, select a deliberate duplicate key, and normalize the delimiter before conversion. This produces smaller JSON and makes it easier to explain why row counts changed.

Validate the result against the source

Format the JSON and confirm it parses. Compare object count with the final CSV row count, inspect empty cells, and spot-check identifiers, dates, quotes, and multiline values before importing the result elsewhere.

CSV values that need a decision

CSV valueSafer defaultReason
00127StringA number conversion removes leading zeroes
2026-08-09StringDate parsing and time zones vary by destination
TRUEString unless the schema says BooleanCapitalization alone does not define a type
Empty fieldEmpty string or explicit null by agreementThe two values are not interchangeable