CSV ↔ JSON Converter
Convert between CSV and JSON formats instantly.
What It Does
This bidirectional converter transforms CSV (comma-separated values) data into JSON arrays of objects, and converts JSON arrays back into CSV. It runs entirely in your browser — no data is uploaded to any server. Use it to prepare data for APIs, import/export between tools, or convert spreadsheet exports for use in JavaScript applications.
CSV to JSON — How It Works
The first row becomes JSON keys. Each subsequent row becomes an object:
CSV input:
name,age,city
Alice,30,London
Bob,25,Paris
JSON output:
[
{ "name": "Alice", "age": "30", "city": "London" },
{ "name": "Bob", "age": "25", "city": "Paris" }
] JSON to CSV — How It Works
The converter takes the keys from the first object in the array as column headers, then writes one row per object. Keys present in later objects but absent in the first will be missing from those columns — ensure your JSON array has a consistent schema.
Common Use Cases
- Converting database exports (CSV) for use in a REST API (JSON)
- Preparing seed data for development databases
- Transforming Google Sheets / Excel exports for JavaScript apps
- Converting API responses to CSV for stakeholder reports in spreadsheets
- Data migration between systems that use different formats
Tips & Gotchas
- All values from CSV come in as strings. Cast numbers explicitly in your code:
Number(row.age) - Empty CSV cells become empty strings
""in JSON, notnull - Avoid column names with special characters — they become JSON keys and may require bracket notation
Frequently Asked Questions
- Does the converter handle CSV files with headers?
- Yes. The converter treats the first row of a CSV as the header row and uses those values as keys in the resulting JSON objects. Each subsequent row becomes one JSON object in an array.
- How are CSV fields with commas or quotes handled?
- Fields containing commas must be wrapped in double quotes in the CSV format. If a field contains a double quote, it should be escaped by doubling it (""). The parser follows RFC 4180 conventions for these edge cases.
- Can I convert nested JSON to CSV?
- Nested JSON objects cannot be directly represented in flat CSV format. The converter works best with flat arrays of objects where all values are primitives (strings, numbers, booleans). Nested objects will be serialized as strings.
- What encoding should my CSV use?
- UTF-8 is recommended. The browser-based converter handles UTF-8 text natively. If your CSV was exported from Excel and contains special characters, save it as "CSV UTF-8" from Excel's Save As dialog to avoid encoding issues.
- What is the difference between CSV and JSON for data exchange?
- CSV is compact and ideal for tabular data — spreadsheets, database exports, analytics. JSON supports nested structures and is the standard for APIs and configuration files. Choose CSV for flat tabular data and JSON for hierarchical or API-consumed data.