{
  "id": 18051819,
  "title": "CSV to JSON: the three cases that break every naive parser",
  "url": "https://urgent.news/2026/11/04/csv-to-json-the-three-cases-that-break-every-naive-parser",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-04T01:48:04.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/ii-x-ai/csv-to-json-the-three-cases-that-break-every-naive-parser-2idl"
  },
  "original_language": "en",
  "account": "CSV files have a complex quoting ruleset that many hand-written parsers ignore. There are three key inputs that break these parsers, causing columns to shift by one. Case 1 involves a comma inside quotes; this leads to a fourth column being created and the price disappearing. Case 2 occurs when doubled quotes are treated as an escape, not a close, resulting in the field being split incorrectly. Case 3 introduces a Byte Order Mark (BOM) in UTF-8 files, causing the first header to become undefined in JSON. To resolve these issues, it is crucial to first strip the BOM, normalize line endings, split records respecting quotes across newlines, and then parse each record. These steps ensure proper mapping of the first row to headers and accurate conversion of CSV files to JSON.",
  "summary": "A CSV file is not comma-separated. It is comma-separated, with a quoting ruleset that almost every hand-written parser ignores . Three inputs break the naive version, and all three fail the same way: your columns silently shift by one. Case 1 — a comma inside quotes sku,name,price 00127,Widget, small,45.20 Naive line.split(',') gives you four fields for three columns. The price lands in a fourth…",
  "key_points": [
    "Comma inside quotes creates extra column and loses data",
    "Doubled quotes treated as escape, splitting fields incorrectly",
    "Byte Order Mark (BOM) in UTF-8 files makes first header undefined"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}