Complete Guide to CSV and JSON Conversion
What is CSV and when should you use it?
CSV (Comma-Separated Values) is a plain-text format for tabular data. Each line is a row, and fields within a row are separated by a delimiter character — typically a comma. The first row is usually a header that names each column. CSV has no standard for data types: every field is a string. Consuming code must parse numbers, dates, and booleans from strings. CSV is universal: every spreadsheet application, database, BI tool, and data pipeline tool can read and write it. It is the lowest common denominator for data exchange. Use CSV when you need human-readable tabular data that can be opened in Excel or Google Sheets, when you are exporting from or importing into a database, or when you are sending data to a non-developer stakeholder.
What is JSON and when should you use it?
JSON (JavaScript Object Notation) is a text format for structured data that natively represents strings, numbers, booleans, null, arrays, and nested objects. Unlike CSV, JSON is typed: a number field is stored as a number, not a string that looks like a number. JSON is the lingua franca of REST APIs, configuration files, and modern web applications. Use JSON when your data has nested structure (objects within objects, arrays within objects), when you need to preserve data types, when you are communicating with an API, or when you are working in a JavaScript-based application. JSON is harder to read in a spreadsheet, which is why converting to CSV is useful for sharing data with non-technical stakeholders.
RFC 4180: the CSV standard you need to know
RFC 4180 is the closest thing CSV has to an official specification. Key rules: fields may be enclosed in double quotes; if a field contains the delimiter, a newline, or a double quote, it must be enclosed in double quotes; a double quote inside a quoted field is escaped by doubling it ('""'). Example: the value 'New York, NY' becomes '"New York, NY"' in a comma-delimited file. A value containing a double quote (say: he said "hello") becomes '"he said ""hello"""'. Many CSV generators do not follow RFC 4180 strictly — they may omit quotes when not strictly necessary, or use backslash escaping instead of doubling. This tool parses both correctly and generates strictly RFC 4180-compliant output.
Common CSV problems and how to diagnose them
Delimiter mismatch: the most common problem is that the file uses semicolons (common in Europe and some locales) but the parser expects commas. If your JSON output has one key per row containing the entire row as a string, you have a delimiter mismatch. Change the delimiter in the Options panel. Encoding issues: CSV files created on Windows may use Windows-1252 encoding (not UTF-8). Characters like curly quotes, em dashes, and accented letters will appear as garbage. Re-save the file as UTF-8 in your text editor or spreadsheet application. Inconsistent quoting: if a CSV generator quotes fields inconsistently, some parsers will fail. This tool is lenient: it handles both quoted and unquoted fields in the same file. Embedded newlines: if a field contains a newline, it must be quoted. A parser that splits on newlines without respecting quotes will incorrectly split the field into two rows.
How to convert CSV to JSON in JavaScript
There is no built-in CSV parser in JavaScript — you need either a library or a custom implementation. For simple cases (no quoted fields, no embedded newlines): split by newline to get rows, split each row by comma to get fields, use the first row as keys. For production use, use a library like Papa Parse (papaparse.com), which handles all RFC 4180 edge cases, streaming large files, web workers, and type coercion. Example: Papa.parse(csvString, { header: true, dynamicTyping: true }). The dynamicTyping option auto-converts numbers and booleans from strings — exactly what this tool's 'Parse numbers' and 'Parse booleans' options do. For Node.js server-side parsing, csv-parse (part of the csv package) is the most complete RFC 4180-compliant parser.
How to convert JSON to CSV in JavaScript
The standard approach: collect all unique keys across all objects in the array (to handle sparse data where different objects have different keys), write the header row, then write one row per object with values in header order. Fields containing the delimiter, newline, or double quote must be quoted and internal double quotes doubled. In Node.js, the csv-stringify library handles this correctly. For browser use, Papa Parse's unparse() function accepts an array of objects and returns CSV. In Python, the built-in csv module provides csv.DictWriter, which takes a list of dicts and writes them as CSV rows. Always specify the fieldnames parameter to control column order.
Working with TSV (Tab-Separated Values)
TSV is identical to CSV except the delimiter is a tab character instead of a comma. TSV is common in bioinformatics, database exports, and some programming environments. One advantage of TSV: since commas rarely appear in numeric or identifier fields, TSV files often need no quoting at all, making them simpler to parse with basic string splitting. The quoting rules from RFC 4180 still apply when a field contains a tab or newline. This tool supports TSV by selecting Tab as the delimiter in the Options panel. When downloading output, files use the .csv extension regardless of delimiter — rename to .tsv if needed for downstream tools that detect format by extension.