Skip to content
gohacks.dev
Tooling

CSV to JSON Converter

Convert CSV to an array of JSON objects and JSON back to CSV, with quoted fields, delimiter detection, type detection and nested objects flattened to columns.

Free · No sign-up · Your inputs stay in your browser

Input

Convert CSV to JSON and back

Output

Result

3 records, 5 columns

Quoting follows RFC 4180: a field with the delimiter, a quote or a line break is wrapped in double quotes, and quotes inside are doubled. Nested objects are flattened to dot.separated columns; arrays are written as JSON text. Excel in many European locales expects a semicolon.

Runs in this browser. Nothing you paste is sent to a server.

Quoting rules

RFC 4180 is short: a field containing the delimiter, a double quote or a line break is wrapped in double quotes, and a double quote inside it is written twice. Splitting lines on commas ignores all of that and breaks on the first address with a comma in it. PHP's fgetcsv() and str_getcsv() follow the RFC, with one quirk: their escape character is a backslash by default, which changes how \" is read. Pass an empty string as the escape parameter for strict RFC behaviour.

Excel and semicolons

In locales that use a comma as the decimal separator, including most of Europe, Excel saves and expects CSV separated by semicolons. Exporting for those users, either use semicolons or start the file with sep=,.

Types

CSV has no types, so every value arrives as text. Type detection turns 42 into a number, which is wrong for ZIP codes and phone numbers with leading zeros; turn it off for those columns.

Share

Frequently asked questions

How do I convert CSV with semicolons?
Leave the delimiter on Detect, or choose Semicolon. The first row decides which delimiter is used.
What happens to nested JSON when converting to CSV?
Nested objects become columns named with dots, such as address.city. Arrays are written as JSON text in a single cell.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools