CSV ↔ JSON Converter
Convert between CSV and JSON formats.
About this tool
CSV (Comma-Separated Values) is a plain-text format for tabular data: each line represents one row, and values within a row are separated by a delimiter. The delimiter is typically a comma, but semicolons are common in European locales (where commas are used as decimal separators), and tabs are used in TSV (Tab-Separated Values) files. CSV is supported by every spreadsheet application, relational database, data analysis library, and ETL tool, making it the universal lingua franca for tabular data exchange.
JSON arrays of objects are the standard way to represent tabular data in web APIs and JavaScript applications. Each row of the CSV becomes a JSON object, and the keys of each object come from the CSV header row. This format is self-describing — field names travel with every record — unlike CSV where the header row may be separated from the data rows or absent entirely. The tradeoff is verbosity: field names are repeated for every row, making JSON significantly larger than CSV for wide tables.
The CSV format has well-known edge cases that a correct parser must handle. Values containing the delimiter character, double quotes, or newlines must be enclosed in double quotes. A double quote character inside a quoted value is escaped as two consecutive double quotes (RFC 4180). Values containing only whitespace are valid. The last row may or may not have a trailing newline. Fields may be empty. Most simple CSV parsers built with string splitting fail on at least one of these cases.
Converting from JSON to CSV loses information when the JSON contains nested objects or arrays, since CSV is inherently flat. Common strategies are: flatten nested objects using dot notation as key names (user.name, user.email), serialize nested values as JSON strings within a CSV cell, or expand array fields into multiple rows. The right strategy depends on how the resulting CSV will be consumed. For simple flat objects, the conversion is lossless in both directions.
CSV is the primary format for importing and exporting data between different systems: databases export query results as CSV, spreadsheet applications import and export CSV, data pipelines use CSV as an intermediate format between processing stages, and APIs sometimes support CSV responses for bulk data retrieval. When parsing CSV from external sources in production code, always use a battle-tested CSV library rather than splitting on commas — the edge cases are numerous and consequential.