# CSV to JSON Converter

URL: https://hifreetools.com/developer/csv-to-json

> Convert CSV or TSV into a clean JSON array of objects, or turn a JSON array back into CSV. Pick your delimiter, choose whether the first row is a header, and download the result.

## Quick answer

To convert CSV to JSON, paste your CSV and the tool uses the first row as the object keys, producing a JSON array where each later row becomes one object. A built-in RFC 4180 parser handles quoted fields with commas and "" escaped quotes, so values are split correctly. It also converts a JSON array of objects back into CSV, and everything runs locally in your browser.

Paste CSV (or TSV) and the converter reads it row by row with a small RFC 4180 parser. A double quote starts a quoted field, two double quotes ("") inside a quoted field mean a literal quote, and the chosen delimiter or a newline inside quotes is treated as part of the value rather than a separator. When "First row is a header" is on, that first row supplies the object keys and every following row becomes one JSON object; with it off you get a JSON array of arrays. Optional type coercion turns cells that exactly match a number, true, false, or null into the matching JSON type — otherwise every value stays a string. The JSON to CSV direction reverses this: it collects the union of object keys (in first-seen order) for the header, then writes one row per object, automatically quoting any value that contains the delimiter, a quote, or a newline. All parsing happens in your browser; nothing is uploaded.

## Examples

- Basic CSV to JSON (values as strings): a,b 1,2 (header on, type coercion off) → [ { "a": "1", "b": "2" } ]
- Quoted field with a comma: name,city "Smith, John",NYC → [ { "name": "Smith, John", "city": "NYC" } ]
- Escaped quotes inside a value: quote "She said ""hi""" → [ { "quote": "She said \"hi\"" } ]
- JSON array back to CSV: [{"a":1,"b":2},{"a":3,"b":4}] (JSON → CSV, header on) → a,b 1,2 3,4

## FAQ

**Does the first row become the JSON keys?**
Yes, when 'First row is a header' is enabled the first CSV row supplies the keys for every object. Turn it off to get a plain JSON array of arrays where no row is treated as keys.

**Can it handle commas and quotes inside a field?**
Yes. The parser follows the RFC 4180 convention: wrap a value in double quotes to include the delimiter or a newline, and use two double quotes ("") to represent a literal quote inside that value.

**How do I convert TSV (tab-separated) files?**
Choose 'Tab ( TSV )' from the Delimiter menu. The same parser then splits on tabs instead of commas, and everything else works identically.

**Are numbers kept as text or converted to real numbers?**
That is your choice. With 'Convert numbers / true / false / null' enabled, cells that exactly match a number or a JSON literal become real JSON types; with it disabled, every value stays a string.

**Can I convert JSON back into CSV?**
Yes. Switch to the JSON → CSV tab and paste a JSON array of objects. The tool builds a header from the union of all keys and quotes any value that contains the delimiter, a quote, or a newline.

**Is my data uploaded to a server?**
No. All parsing and conversion run entirely in your browser using JavaScript, so your CSV and JSON never leave your device.


## Sources

- [RFC 4180 — Common Format for CSV Files (IETF)](https://www.rfc-editor.org/rfc/rfc4180)
- [MDN — JSON.parse() and JSON.stringify()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON)
- [Wikipedia — Comma-separated values](https://en.wikipedia.org/wiki/Comma-separated_values)

Runs in the browser; nothing is uploaded. Cite as: HIFreeTools, "CSV to JSON Converter", https://hifreetools.com/developer/csv-to-json
