Article

Why Parsing CSV Is Trickier Than Just Splitting on Commas

Published 2026-09-14

The naive approach seems obvious

CSV stands for "comma-separated values," so it seems reasonable to assume you can parse it by just splitting each line on commas. This works for simple data, but breaks the moment a real-world value contains a comma of its own — an address like "New York, NY," for instance.

How CSV actually handles that case

The CSV format solves this by allowing a field to be wrapped in double quotes when it contains a comma (or a line break) that shouldn't be treated as a delimiter. A properly quoted field like "New York, NY" is understood as one single value, comma and all. A literal double-quote character inside a quoted field is itself escaped by doubling it ("").

Why a simple comma-split silently produces wrong data

A naive parser doesn't error out on a quoted comma — it just silently splits the field into two, shifting every subsequent column in that row over by one. This is a particularly dangerous kind of bug, since the output looks like valid data; it's just wrong, and easy to miss until it causes a problem downstream.

Try it yourself

Our CSV to JSON Converter correctly handles quoted fields (including embedded commas and escaped quotes) in both directions, so real-world CSV data converts accurately.

Ready to try it yourself?
Open the CSV to JSON Converter →