What is CSV?
CSV (Comma-Separated Values) is one of the oldest and most universal data formats. Each line in a CSV file represents a row of data, and values within a row are separated by commas. The first line typically serves as the header row, defining column names. CSV files can be opened by virtually any spreadsheet application, database tool, or programming language.
Despite its simplicity, CSV has quirks. Values containing commas must be wrapped in double quotes. Double quotes within a value are escaped by doubling them. There is no standard way to represent data types, so numbers, dates, and booleans are all stored as plain text and must be parsed by the consuming application.
JSON vs CSV
JSON (JavaScript Object Notation) and CSV serve different purposes. JSON excels at representing hierarchical, nested data structures with explicit types (strings, numbers, booleans, nulls, arrays, objects). CSV is optimized for flat, tabular data where every record has the same columns. JSON is the standard for APIs and configuration; CSV is the standard for data exchange with spreadsheets and databases.
When converting JSON to CSV, nested objects must be flattened because CSV only supports two dimensions (rows and columns). When converting CSV to JSON, the result is an array of objects where each column header becomes a key.
How to Use This Converter
- Paste a JSON array of objects or CSV data into the input panel.
- Click JSON to CSV or CSV to JSON depending on the direction of conversion.
- Review the output, including the column preview showing detected field names.
- Click Copy to copy the converted data to your clipboard.
Frequently Asked Questions
What is CSV?
CSV (Comma-Separated Values) is a plain-text file format that stores tabular data. Each line represents a row, and values within a row are separated by commas. CSV files can be opened by any spreadsheet application (Excel, Google Sheets) and are one of the oldest and most widely supported data exchange formats.
When should I use CSV vs JSON?
Use CSV when your data is flat and tabular, you need to import into spreadsheets, or you are working with large datasets where file size matters. Use JSON when your data has nested or hierarchical structure, you are working with APIs, or you need to preserve data types (numbers, booleans, nulls).
Can CSV have nested data?
No. CSV is inherently flat: it represents two-dimensional tables with rows and columns. If your JSON has nested objects or arrays, they must be flattened to fit CSV format. Common approaches include dot notation for nested keys (e.g., address.city), JSON-encoding nested values as strings, or splitting into multiple CSV files.
How do I handle commas in CSV values?
Values containing commas must be enclosed in double quotes. For example: "New York, NY" is a single field. If the value also contains double quotes, they are escaped by doubling them: "She said ""hello""". This convention is defined in RFC 4180.
What is a TSV file?
TSV (Tab-Separated Values) is a variant of CSV that uses tab characters instead of commas as delimiters. TSV is useful when data values frequently contain commas, since tabs are less common in natural text. TSV files are supported by spreadsheet applications and many data processing tools.
How do I convert JSON arrays to CSV?
A JSON array of objects converts naturally to CSV: each object becomes a row, and the object keys become column headers. The converter collects all unique keys across all objects for the header row, then fills in each row's values. Missing keys in individual objects result in empty cells.