Toolphy

CSV to JSON Converter

Paste CSV with a header row and get a clean JSON array of objects — delimiter detected automatically and quoting handled correctly.

0
Rows
0
Columns

How to Convert CSV to JSON

Moving tabular data into an application usually means converting a spreadsheet export into JSON. This tool reads your CSV in the browser and builds a JSON array of objects in a few seconds.

  1. Paste your CSV. Copy the contents of a spreadsheet or a .csv file — including the header row — and paste it into the input box. Every following line becomes one JSON object and each header becomes an object key.

    Example: a file containing the header name,age and the rows Ada,36 and Linus,54 becomes [{"name":"Ada","age":"36"},{"name":"Linus","age":"54"}].

  2. Pick the delimiter. Leave it on Auto-detect and the tool inspects the first line to choose between comma, semicolon and tab. Override it manually when a file mixes conventions or the header itself contains delimiters.

  3. Choose the output shape. Pretty-print adds indentation so the JSON is readable in a code editor and in diffs; turn it off for the most compact payload.

  4. Press Convert, then copy or download. The tool shows the row and column counts and lets you copy the JSON to the clipboard or save a .json file with one click.

What Is CSV to JSON Conversion?

CSV (comma-separated values) is a flat, line-oriented format where each row is a record and each field is separated by a delimiter. JSON (JavaScript Object Notation) is a hierarchical format built from objects, arrays and typed scalars. Converting CSV to JSON is a lift rather than a flatten: the columns named in the header row become the keys of each object. The header row is what gives the output meaning. Without it a parser can only produce arrays of values, which are hard to use in application code. This tool always treats the first row as the header, so a spreadsheet column called email turns into a predictable email property on every object. Real CSV is more subtle than splitting on commas. Fields may be wrapped in double quotes so they can contain the delimiter, a line break or a quote character itself; a literal quote inside a quoted field is written twice, as "" . The parser here follows the RFC 4180 convention for those cases, so a field like "Paris, France" stays in one cell instead of being split into two. All parsing runs locally with native JavaScript. Your data is never uploaded to a server, which matters when the CSV holds personal or commercially sensitive records.

Common Applications

1. Seeding a database: turn a spreadsheet of products, users or posts into JSON that can be inserted directly through an API or an import script.

2. Front-end mock data: convert a small CSV list into a JSON fixture for tests, Storybook stories or a prototype without hand-writing the objects.

3. API payloads: reshape a table exported from a back office into the array-of-objects shape that most REST endpoints expect.

4. Data analysis pipelines: load a CSV into a JavaScript or Node.js project as structured records rather than re-parsing text on every run.

5. Configuration files: keep a readable spreadsheet as the source of truth, then regenerate a JSON config file whenever it changes.

How Quoted Fields and Line Breaks Are Handled

The hard part of CSV is that commas and line breaks are both meaningful and also allowed inside a value. RFC 4180 solves this with double quotes: any field containing the delimiter, a double quote or a newline is enclosed in quotes, and an internal double quote is escaped by doubling it.

Consider a field written as "Smith, John". A naive split on the comma would produce two columns, but this tool recognises the opening quote, keeps the comma inside the field and returns the single string Smith, John. A value containing a quote, such as He said ""hello"", is decoded back to He said "hello", and a quoted field may even span several physical lines, which is common in exported addresses or free-text comments.

Because the parser tracks quote state character by character, embedded newlines never start a new record. If a quoted field is left open at the end of the file, the input is malformed and the tool reports it instead of returning broken data. Empty fields become empty strings, so a row with a trailing comma still produces the expected key with an empty value.

The result is a faithful, lossless conversion: the JSON keeps exactly the characters that were in the CSV, without the quoting artefacts that a simple string split would leave behind.

Guides

Frequently Asked Questions - FAQ

Is my data sent to a server?

No. The entire conversion happens locally in your browser using native JavaScript. Your CSV is never uploaded, logged or stored anywhere.

How does the automatic delimiter detection work?

The tool scans the first line — ignoring delimiter characters that sit inside quoted fields — and counts occurrences of comma, semicolon and tab. The character that appears most often is chosen. You can always override it manually.

Does the CSV need a header row?

Yes. The first row is always treated as the header and its cell values become the property names of every JSON object. If the header is missing or empty, the tool asks you to provide one so the output stays meaningful.

How are quoted fields with commas or newlines handled?

Fields wrapped in double quotes follow RFC 4180: delimiters and line breaks inside them are preserved as part of the value, and a doubled quote is decoded back to a single quote. An unclosed quote is reported as malformed input.

Can I get compact or pretty-printed JSON?

Both. Pretty-print indents the output with two spaces for readability, while turning it off produces the smallest possible payload for APIs, storage or network transfer.

Last updated: