CSV ↔ JSON Converter ⚡
Convert CSV data to JSON arrays/objects and vice versa. Auto-detects delimiters.
Understanding CSV and JSON
CSV (Comma-Separated Values) and JSON (JavaScript Object Notation) are two of the most popular formats for exchanging structured data.
- CSV: Uses a tabular format, where each line represents a row, and fields are separated by commas (or other delimiters like tabs or semicolons). It's highly compact and widely supported by spreadsheet applications like Excel and Google Sheets.
- JSON: Uses a hierarchical format based on key-value pairs and arrays. It can represent complex nested structures, making it the standard for web APIs and modern applications.
How the Conversion Works
CSV to JSON
When converting from CSV to JSON, you can choose two common formats:
- Array of Objects (Default): The first row of the CSV is treated as headers (keys), and each subsequent row becomes an object containing those keys mapped to their respective row values.
- 2D Array: Each row is converted into an array of values, creating an array of arrays. This preserves the exact tabular structure without assuming the first row is a header.
This tool automatically detects delimiters (comma, tab, semicolon) and correctly handles edge cases like quoted fields containing commas or newlines.
JSON to CSV
To convert JSON to CSV, the input must be an array of objects or an array of arrays. The converter will automatically extract all unique keys from the objects to generate the header row. Any missing values for a specific key in an object will be represented as empty fields in the CSV.
Tips for Data Conversion
- Ensure your CSV headers (if present) don't contain unexpected characters that might cause issues when used as JSON keys.
- When converting nested JSON objects to CSV, remember that CSV is fundamentally flat. Nested objects will be stringified in the resulting CSV field. You may need to flatten your JSON structure before converting for the best results.
- This tool runs entirely in your browser. Your data is never sent to a server, ensuring complete privacy and allowing you to convert large datasets locally.