// JSON output will appear here
CSV to JSON Converter
Convert CSV (Comma-Separated Values) data to JSON (JavaScript Object Notation) format instantly in your browser. This free online tool handles all CSV edge cases including quoted fields, embedded commas, newlines within quotes, and custom delimiters. No data leaves your device — all conversion happens client-side.
How to Convert CSV to JSON
- Paste your CSV data into the input textarea, or use the
Upload CSVbutton to load a file. - Choose your delimiter (comma, tab, semicolon, or pipe).
- Toggle Header row if your first row contains column names.
- Select output format: Array of objects (key-value pairs) or Array of arrays.
- The JSON output updates automatically as you type. Use Copy or Download JSON to save the result.
JSON to CSV Conversion
Switch to the JSON → CSV tab to convert JSON arrays back to CSV. The tool detects keys from the first object and writes them as headers, then serializes each row. Values containing commas, quotes, or newlines are automatically quoted per RFC 4180.
Supported CSV Edge Cases
- Quoted fields:
"hello, world"is treated as a single field. - Escaped quotes: Double quotes inside fields are handled (
""→"). - Newlines in quotes: Multi-line fields wrapped in quotes are preserved.
- Custom delimiters: Tab-separated (TSV), semicolon, and pipe-delimited files are supported.
When to Use CSV vs JSON
CSV is ideal for spreadsheet data, database imports, and tabular datasets. JSON is preferred by APIs, web applications, and NoSQL databases. Converting between the two formats is common when moving data between spreadsheets and web services, preparing config files, or feeding data into JavaScript applications.
Privacy & Security
All conversion is performed entirely in your browser using vanilla JavaScript. Your data is never sent to any server, making this tool safe for sensitive or confidential information.
How CSV Parsing Actually Works
CSV looks trivial — split on commas — until it isn't. The governing convention, RFC 4180, defines fields that may be wrapped in double quotes, and inside those quotes everything changes: commas no longer separate fields, and even line breaks are just characters within the field. A quoted "Smith, John" is one value, not two. Double quotes inside a quoted field are escaped by doubling them, so "He said ""hi""" decodes to He said "hi". This converter implements that state-machine logic: it tracks whether it is inside quotes character by character, which is the only correct way to parse real-world CSV and the reason naive comma-splitting corrupts exported data.
Delimiter choice matters for the same reason. European locales often export semicolon-delimited CSV because the comma is the decimal separator; analytics exports frequently arrive tab-separated. The tool handles comma, tab, semicolon, and pipe delimiters in both conversion directions.
Header Rows and Output Shapes
With Header row enabled, the first line supplies keys and every subsequent line becomes an object keyed by column name — the shape most APIs and ORMs expect ([{"name": "Alice", "age": 30}]). With it disabled, or with Array of arrays selected, rows stay positional ([["Alice", 30]]), which suits numeric workloads, spreadsheets round-trips, and datasets where column names are meaningless. Both shapes are valid JSON; which one you want depends entirely on what the consumer of the data expects.
CSV vs JSON vs Other Data Formats
Every tabular format makes different trade-offs between human readability, type fidelity, and tooling. The table below compares the formats you are most likely choosing between when converting data.
| Format | Structure | Types | Best for |
|---|---|---|---|
| CSV | Rows and columns | Everything is text | Spreadsheets, database imports, simple exports |
| JSON | Nested objects and arrays | Strings, numbers, booleans, null | APIs, config files, JavaScript apps, NoSQL stores |
| TSV | Rows and columns | Everything is text | Analytics exports, bioinformatics pipelines |
| XML | Arbitrary tree | Text plus schema-defined | Enterprise and legacy document interchange |
| YAML | Nested mappings | Scalars, lists, maps | Configuration files read by humans |
| Parquet | Columnar | Rich binary types | Big-data analytics and columnar storage |
The conversion asymmetry is worth noting: CSV to JSON loses nothing, but JSON to CSV cannot represent nesting — arrays and objects inside values are stringified, because a flat row has nowhere to put them. Flat JSON converts perfectly both ways; deeply nested JSON is better sent as JSON.
Typing and Edge Cases to Expect
CSV cells are always text, so the JSON output of this tool preserves that fidelity: 30 in a spreadsheet export becomes the string "30" unless you post-process numbers yourself. That is the safe default — silently coercing text to numbers is how ZIP codes lose leading zeros and product codes become scientific notation. Also expect ragged rows in hand-edited CSV: when a row has fewer fields than the header, this parser fills the missing trailing fields rather than shifting data, and rows with extra fields keep their extras. Empty trailing lines, a BOM at the start of Windows exports, and CRLF line endings are all handled without polluting the output.
Workflow Patterns
A few repeated patterns cover most real conversions. Moving spreadsheet data into an app: export CSV, convert with header row on, paste the JSON array into a fixture or seed file. Feeding a charting library: most expect an array of objects keyed by series name — exactly the header-row output. Debugging an API: convert the JSON response to CSV, eyeball it in a spreadsheet grid, convert back after edits. Data cleaning is often fastest in the format you can see: sort and filter in CSV, then convert once the rows are right, since JSON's strength is transport and nesting, not eyeballing a thousand rows.
Frequently Asked Questions
How do I convert a CSV file to JSON?
Paste the CSV text into the input panel or use the Upload CSV button, then enable Header row if your first line contains column names. The JSON output updates automatically; use Copy or Download JSON to save it.
How do I convert JSON back to CSV?
Switch to the JSON → CSV tab, paste an array of objects, and click Convert. Keys from the first object become the header row, and values containing commas, quotes, or newlines are quoted automatically per RFC 4180.
Does the converter handle commas inside fields?
Yes. Fields wrapped in double quotes may contain commas, quotes (doubled per RFC 4180), and even line breaks. The parser tracks quote state character by character, so quoted content is never split.
Are numbers converted to JSON numbers?
No — CSV cells are text, so values become JSON strings by default. This preserves data like ZIP codes with leading zeros. Convert types after conversion if your consumer needs numbers.
Is my data uploaded anywhere?
No. Both converters run entirely in your browser. Nothing is transmitted, logged, or stored, so the tool is safe for sensitive datasets.