CSV to JSON Converter

Convert CSV data to JSON format, using the first row as headers.

About This Tool

What this tool does

The CSV to JSON Converter takes delimited text (comma-, tab-, semicolon-, or pipe-separated) and turns it into a JSON array of objects. The first row of your input becomes the keys, and every row below it becomes one object in the array. Paste your data on the left, pick the matching delimiter on the right, and the JSON appears in the Result card the moment your input has enough rows to make sense.

The conversion runs entirely in your browser as you type. There is no upload, no server round-trip, no log. That makes it usable for internal spreadsheets, customer exports, half-finished data dumps, and anything else you would rather not paste into a random website's text box. Once the page has loaded you can disconnect from the network and the tool will still work.

Who actually needs this

Anyone who has data in a spreadsheet and needs it in a form a piece of code can consume. A few concrete cases:

  • Front-end developers seeding a mock API or a static list (products, team members, FAQ entries) from a CSV the marketing team handed over.
  • Engineers pasting a few rows from a database query result into a Postman or fetch body that expects JSON.
  • Analysts and ops people getting a TSV export out of a BI tool or a Google Sheet copy-paste, and needing JSON for a webhook payload.
  • Anyone wiring up a quick prototype who has a spreadsheet of test data and does not want to write a parser by hand.

If you are working with thousands of rows or untrusted-CSV-from-the-internet edge cases, you want a real parser (more on that below). For a few hundred rows of data you control, this is faster than installing a library.

How to use it

The page has two inputs and one output.

  • CSV Input. Paste your data into the textarea. The first line must be the header row (the column names you want as JSON keys). Every line below it is one record. The placeholder hints at the shape with a sample header name,age,city followed by two example rows for Alice and Bob.
  • Delimiter. Pick the character that separates fields in your data. Options are Comma (,) (default), Tab, Semicolon (;), and Pipe (|). If you do not know which one you have, look at your file in a text editor; whatever sits between the column values is your delimiter.
  • Result. The JSON Output card appears automatically as soon as you have at least a header row and one data row. There is no Convert button. A Copy button on the right copies the output to your clipboard.

If you only paste one line, the output reads "Need at least a header row and one data row" rather than JSON. That is the tool telling you it does not have enough to work with yet, not an error in your data.

How the conversion works

The parser is deliberately simple, and knowing exactly what it does saves you a lot of guessing when something looks off. Step by step:

  1. The whole input is trimmed of leading and trailing whitespace, then split on newline characters (\n).
  2. The first resulting line is split on your chosen delimiter. Each piece is trimmed and becomes a header (a JSON key).
  3. Every remaining line is split on the same delimiter. The first value is paired with the first header, the second with the second header, and so on.
  4. Each value is trimmed of surrounding whitespace as it is assigned.
  5. The resulting array of objects is serialized with JSON.stringify(data, null, 2), meaning two-space indentation, sorted in original row order.

Two consequences of this design are worth pinning down because they trip people up:

  • Every value stays a string. The number 30 in your CSV becomes the string "30" in the JSON. The boolean-looking word true becomes "true". The empty cell becomes "". The tool never guesses types. This is annoying for math but it protects ZIP codes, phone numbers, and IDs with leading zeros (007) from being silently turned into 7 the way many auto-typing parsers do.
  • The split is literal. If you choose Comma as the delimiter, the parser splits on every comma in a line, including commas inside quoted fields. There is no RFC 4180 quote handling. The field "Smith, John" in a comma file becomes two values, and the double quotes are kept as part of the text. If your data has the delimiter inside its values, you need a different delimiter or a different parser.

Worked example

Paste this in with the Comma delimiter selected:

name,age,city
Alice,30,NYC
Bob,25,LA
Carol,42,Chicago

You get back the JSON below. Because the serializer uses JSON.stringify(data, null, 2), each key sits on its own indented line:

[
  {
    "name": "Alice",
    "age": "30",
    "city": "NYC"
  },
  {
    "name": "Bob",
    "age": "25",
    "city": "LA"
  },
  {
    "name": "Carol",
    "age": "42",
    "city": "Chicago"
  }
]

Note that 30, 25, and 42 are strings in the output, not numbers. If you want them as numbers in your downstream code, cast them there: Number(row.age) in JavaScript, int(row["age"]) in Python.

Mismatched row lengths

Real spreadsheets are messy. The tool handles two specific kinds of mismatch silently rather than erroring:

  • Row has fewer values than headers. The missing trailing keys get an empty string. So if your header is name,age,city and a row is just Dave,28, the resulting object is { "name": "Dave", "age": "28", "city": "" }.
  • Row has more values than headers. The extra values are dropped, with no warning. If a row is Eve,33,Boston,extra, the extra is gone from the JSON.

This is convenient when you are pasting partial data, and dangerous when it hides a real problem (most often: a stray comma inside a value pushed every later column off by one). If your JSON looks weirdly truncated or empty in the wrong places, count the commas in a suspect row before you blame the tool.

Common pitfalls

  • Wrong delimiter selected. The most common failure mode. A semicolon-separated file parsed as Comma turns each row into a single huge key with one giant value. If your output has one weird-looking key per row, change the delimiter dropdown and try again.
  • Commas inside quoted strings. Addresses, names with titles ("Smith, Jr."), and free-text comments are the usual culprits. Either switch the source to Tab or Pipe (neither typically appears inside the data), or pre-process the file with a real CSV library.
  • No header row. If your file starts with real data instead of column names, the parser will consume your first record as the header and you will get keys like "Alice", "30", and "NYC". Add a header row yourself first.
  • Smart quotes from rich-text sources. Pasting from Word, Google Docs, a PDF, or a chat app sometimes substitutes curly quotes (the slanted ones) for straight quotes. The trim step strips whitespace, but it does not normalise character classes, so any curly quote that ends up mid-value will sit there in your JSON looking identical to a regular one but failing string comparisons in your downstream code. Paste through a plain text editor first if your source is rich text.
  • Extra blank lines. An empty line in the middle of your input becomes an object with every header key present but every value empty (e.g. {"name":"","age":"","city":""}). Strip blank lines from the source before pasting.
  • Leading or trailing spaces in cells. These are trimmed for you. name, age, city with spaces still produces clean keys "name", "age", "city". The same per-value trim also strips stray carriage returns from Windows (CRLF) line endings, so mixed Unix and Windows line endings are not something you need to clean up before pasting.

When NOT to use this tool

The simple split-on-delimiter approach is fine for clean, hand-rolled data. It is the wrong tool when:

  • Your CSV uses RFC 4180 quoting. If fields can contain the delimiter, newlines, or embedded quotes (escaped as ""), use a proper parser. In a browser, Papa Parse is the standard. In Python, csv.DictReader is built in. In Node, csv-parse is the usual pick.
  • You need typed values. If you want numbers as numbers and booleans as booleans without post-processing, this tool will not give you that. Most full parsers have an option for it.
  • Your file is very large. Everything runs in the page, so a 50 MB CSV will lock up your tab. Anything that big belongs in a script.
  • Your data has multi-line cells. The parser splits on every \n in the input. If a single field contains a newline (an address with a line break, a long description), it will be torn across multiple rows.
  • You need nested JSON. The output is always a flat array of flat objects. There is no way to ask for nesting like { user: { name: ... } }; do that in code after exporting.

Sensible defaults to start with

If you are not sure what you have, try this order:

  1. Leave the dropdown on Comma and paste your data. If the JSON looks right, you are done.
  2. If every row becomes one giant key, change to Tab. Spreadsheet copy-paste is usually tab-separated.
  3. If you are dealing with a European-locale export, try Semicolon. Many European spreadsheet tools use it because the comma is the decimal separator in those locales.
  4. If nothing looks right and your data has commas inside values, re-export the file from the original tool with Pipe as the field separator, paste that in, then pick Pipe here.

What to do if the result looks wrong

Run through this quick checklist before assuming the tool is broken:

  • Does the first line of your input look like column names? If not, you have no header.
  • Does the delimiter in the dropdown match the one actually used in your file? Look at one line in a plain text editor and confirm.
  • Are there commas (or whatever your delimiter is) inside any of your field values? If yes, the parser will split them.
  • Are there blank lines in your input? Remove them.
  • Did you paste from Word, a PDF, or a chat app? These sometimes substitute smart quotes that look identical to normal characters but break string comparisons downstream. Paste into a plain text editor first to strip the formatting.

Adjacent tools and concepts

The reverse direction lives at the linked JSON to CSV Converter, which takes a JSON array of objects and produces delimited text using the union of all keys as the header row.

A few related concepts worth knowing:

  • CSV (Comma-Separated Values) is loosely standardised by RFC 4180. "Loosely" because every tool in the wild handles quoting and line endings slightly differently. There is no single "correct" CSV.
  • TSV (Tab-Separated Values) is the de-facto format when you copy cells out of Excel, Google Sheets, or Numbers. Less ambiguity than CSV because tabs rarely appear inside data.
  • JSON (JavaScript Object Notation) is the data format almost every web API speaks. Strings, numbers, booleans, null, arrays, and objects. The output of this tool is always a JSON array of flat objects with all-string values.
  • NDJSON / JSONL (newline-delimited JSON) is what you want when each row is independent and you need to stream. This tool produces a single JSON array, not NDJSON.

The about text and FAQ on this page were drafted with AI assistance and reviewed by a member of the Coherence Daddy team before publishing. See our Content Policy for editorial standards.

Frequently Asked Questions

Why are my numbers showing up as strings (in quotes)?
By design. The converter copies values as text and never guesses types, so 42 becomes "42". That sounds annoying but it protects ZIP codes, phone numbers, and IDs with leading zeros (like 007) from being silently turned into 7, which is what most type-inferring parsers do. If you need real numbers, cast them in your downstream code: Number(row.age) in JavaScript, int(row['age']) in Python.
Commas inside my quoted fields are breaking the output. What's wrong?
The tool splits literally on the delimiter character and does not parse quotes, so "Paris, France" in a comma-separated file gets split into two columns and the double quotes are kept in the text. If your data legitimately contains the delimiter inside fields, either switch the source to a delimiter that does not appear in the data (Tab and Pipe are both supported), or use a full RFC 4180 CSV parser like Papa Parse that understands quoting.
How do I convert a tab-separated (TSV) file?
Paste it in and set the Delimiter dropdown to Tab. A lot of data copied straight out of spreadsheet cells is tab-separated, so try Tab first if Comma is producing one giant column per row.
Why do I need a header row, and what if my data doesn't have one?
The first line of your input becomes the keys on every JSON object, so a header is required. The tool also needs at least one data row below it before producing output; a single line shows "Need at least a header row and one data row". If your file has no header, add a line of column names at the top first, for example id,name,email. Otherwise your real first record gets consumed as the keys.
Is my data uploaded anywhere?
No. The conversion runs locally in your browser as you type. The text you paste never leaves your device, which makes it safe for internal or sensitive data, and it also works offline once the page has loaded.
What happens if a row has more or fewer values than the header?
Mismatches are handled silently. If a row has fewer values than there are headers, the missing trailing keys get an empty string. If a row has more values than headers, the extra values are dropped. No error is shown either way, so if your JSON looks oddly truncated, count the delimiters in a suspect row. Usually one stray delimiter inside a value has pushed every later column off by one.
Can I get nested JSON like { user: { name: ... } }?
No. The output is always a flat array of flat objects, one per data row. If you need nesting, do it in code after exporting by grouping the rows or reshaping them with whatever language you use. CSV itself has no notion of nesting, so any tool that produces nested JSON from a flat CSV is making assumptions about your column names.
Does it handle very large files?
Everything runs in the browser tab, so memory and CPU are whatever your machine has. A few thousand rows is fine. Tens of megabytes will get sluggish or unresponsive. For anything larger than that, use a streaming parser in a script (Python's csv module, Node's csv-parse, jq) rather than a pasted-into-a-browser tool.
Will Windows (CRLF) line endings break the output?
No. Even though the parser splits only on \n, every header and every value is run through JavaScript's String.prototype.trim() before being placed in the JSON. trim() strips \r along with all other whitespace, so the trailing carriage return on each CRLF line gets removed cleanly. You can paste a file with mixed Unix and Windows line endings and the resulting JSON will look identical either way.