CSV/JSON Converter
CSV ⇆ JSON Converter
Convert between CSV and JSON formats. Supports custom delimiters and header options.
CSV Format Reference
Basic Format
name,email,age John,john@test.com,30 Jane,jane@test.com,25
Quoted Fields
"Name","Description" "Product A","Has a, comma" "Product B","Has ""quotes"""
Common Delimiters
,- Comma (default);- Semicolon (EU)\t- Tab (TSV)|- Pipe
Escape Rules
- Use quotes for fields with commas
- Double quotes inside:
"" - Newlines must be quoted
How to Use This Tool
- Choose Conversion Direction: Select "CSV to JSON" to convert spreadsheet data to JSON format, or "JSON to CSV" to flatten JSON objects into tabular format. Each direction has specific options.
- Paste Your Data: Enter CSV data with rows separated by newlines and columns by your chosen delimiter, or JSON data as an array of objects. Click "Load Sample" to see expected formats.
- Configure Options: For CSV: select delimiter (comma, semicolon, tab, pipe), indicate if the first row is headers, and enable whitespace trimming. For JSON: choose whether to include nested objects.
- Click Convert: The converted output appears below. CSV becomes a JSON array of objects with header names as keys. JSON becomes CSV with object keys as column headers. Copy the result for your use.
Technical Details
CSV (Comma-Separated Values) is a plain-text tabular format where rows are lines and columns are delimiter-separated values. The first row typically contains headers. Values with commas, quotes, or newlines must be quoted and internal quotes escaped by doubling (""). The RFC 4180 standard defines the format, though implementations vary.
JSON (JavaScript Object Notation) represents structured data with objects and arrays. For CSV conversion, JSON should be an array of objects with consistent keys. Nested objects are flattened using dot notation (address.city becomes "address.city" column) or serialized as strings. Empty values become empty strings in CSV or null in JSON. When converting JSON to CSV, only the first object's keys define columns—subsequent objects with additional keys may lose data.
Common Mistakes to Avoid
- Missing or Inconsistent Headers: CSV without a header row produces objects with numeric keys (0, 1, 2). If rows have different column counts, data misaligns. Ensure all rows have the same number of fields as the header.
- Nested JSON Losing Structure: Deeply nested JSON objects can't map directly to flat CSV. Child objects become stringified JSON in cells, or must be flattened with dot-notation column names. Plan your structure before converting.
- Delimiter Conflicts: If your data contains commas and you use comma as delimiter, values must be quoted. A common bug: exporting from Excel with semicolon delimiter in some locales, then importing as comma-delimited elsewhere.
Related Tools
Working with configuration files instead of tabular data? Use our YAML/JSON Converter for config format conversion. For validating your JSON structure, try the JSON Validator.
Frequently Asked Questions
Why does my CSV have extra quotes in the output?
Quotes are added when values contain the delimiter, quotes, or newlines. This is correct per RFC 4180. Internal quotes are escaped by doubling (""). Most CSV parsers handle this automatically when reading.
Can I convert nested JSON to CSV?
Partially. Top-level keys become columns directly. Nested objects are either flattened (parent.child becomes column name) or serialized as JSON strings. Arrays are typically stringified. For complex nested data, consider restructuring before conversion.
What happens to null and undefined values?
In CSV output, null and undefined become empty strings (empty cell). When parsing CSV to JSON, empty cells become empty strings, not null. If you need null values, post-process the JSON to convert empty strings to null where needed.