Skip to content
MyToolkit.pro

Code & Data

CSV to JSON

Paste CSV text and get a clean JSON array. Use the first row as object keys or keep rows as arrays, pick the delimiter, and choose pretty or compact output. Your data never leaves this browser.

Private by design: no text is uploaded or stored.

Private by design: no text is uploaded or stored.

Result — options

Try an example

Result

Updates when you convert or change an option.

Rows
0
Columns
0

Table preview

How does the conversion work?

Each CSV line becomes one element of a JSON array. With "First row is header" on, that row supplies the object keys and every later row becomes an object (missing cells are left blank, extra cells beyond the header are dropped); with it off, every row becomes an array of strings. Quoted fields may contain the delimiter, line breaks or doubled quotes following RFC 4180, and all values stay as text so nothing is re-typed or executed.

Converting a CSV export to JSON, step by step

  1. Paste your data into the CSV to convert box. To use a file instead, click "Load from file" or drag the file onto the box. The file is read as UTF-8 text in your browser, up to 2 MB.
  2. Under Delimiter, pick the character that separates your columns. Choose "Comma ( , )" for most exports and "Semicolon ( ; )" for files saved by Excel in locales that use a decimal comma. Choose "Tab" for TSV files or for cells copied straight from a spreadsheet.
  3. Keep First row is header on if the top line holds column names. Turn it off when the file has no header and you want plain arrays.
  4. Leave Pretty-print on to get JSON indented by two spaces. Turn it off to get the whole array on one line, ready to paste into a request body or an environment variable.
  5. Check the Table preview and the Rows and Columns counters before you copy anything. The preview shows the first 20 rows. If Columns says 1 when you expected more, the delimiter is wrong.
  6. Click Copy result to put the JSON on your clipboard, or "Download result" to save it as a file. The output updates as you type and whenever you change an option.

Examples of CSV input and the JSON you get

A comma-separated file with a header row and Pretty-print on:

name,age
John,30
Jane,25
[
  {
    "name": "John",
    "age": "30"
  },
  {
    "name": "Jane",
    "age": "25"
  }
]

A quoted field that contains a comma and a line break, with compact output:

name,note
"Doe, John","line1
line2"
[{"name":"Doe, John","note":"line1\nline2"}]

The line break inside the quotes stays in the value as \n, and the comma does not start a new column. A doubled quote becomes one literal quote, so "12"" pipe" turns into 12" pipe.

The same three lines give a different shape depending on the header option (Pretty-print off):

First row is header CSV input JSON output
off a,b / 1,2 / 3,4 [["a","b"],["1","2"],["3","4"]]
on a,b / 1,2 / 3,4 [{"a":"1","b":"2"},{"a":"3","b":"4"}]

With the header on, values that look like numbers or booleans are kept exactly as typed:

id,qty,active
1,007,true
2,,false
[{"id":"1","qty":"007","active":"true"},{"id":"2","qty":"","active":"false"}]

007 keeps its leading zeros, true stays the string "true", and an empty cell becomes "" rather than null. If your code needs real numbers, cast them after parsing, for example with Number(row.qty).

When a CSV-to-JSON conversion is useful

  • Test fixtures and mock APIs: export a few rows from a database client or a spreadsheet, convert them, and paste the array into a fixture file or a mock server response.
  • Seeding front-end config: a product list kept in a spreadsheet (SKU, name, price) can become a JSON file for a static site generator or a JavaScript app without writing a parser.
  • Checking what an import will see: the preview and counters show how quoting and delimiters are read. That helps when a CSV import elsewhere fails and you need to know whether the file or the importer is at fault.
  • Moving data between tools: many no-code platforms, HTTP clients and NoSQL databases accept JSON arrays but not CSV.

To inspect or reindent a large result, paste it into the JSON Formatter.

Limits and edge cases to know before you convert

The output is always a flat array. A header such as user.name becomes a literal key, {"user.name":"Anna"}, not a nested user object.

With the header option off, every row keeps its own length, so the arrays can differ in size: a,b / 1 / 2,3,4 gives [["a","b"],["1"],["2","3","4"]].

If the chosen delimiter doesn't occur in the file, each line becomes a single field. A comma file read with the semicolon setting gives keys like "a,b". Switch the delimiter and the result updates straight away.

If a quoted field is never closed, the tool shows an error instead of guessing where the field ends: "Invalid CSV — a quoted field is never closed. Unclosed quote opens on line 2." The line number points at the stray quote, so you know which line to fix. Windows (CRLF) and Unix line endings are both accepted.

Text pasted beyond 1,000,000 characters is cut off. For larger data, use "Load from file", which accepts files up to 2 MB.

Frequently asked questions

How do I get a JSON object keyed by ID instead of an array?

The converter always outputs an array, so reshape it after parsing. In JavaScript, `Object.fromEntries(rows.map(r => [r.id, r]))` turns rows with ids 42 and 43 into `{"42":{…},"43":{…}}`.

Why is the Rows count lower than the number of lines in my file?

With First row is header on, the header line isn't counted, and a single newline at the very end of the input is ignored. A quoted field that spans several lines also counts as one row.

Can I convert an Excel .xlsx file straight to JSON?

No, the converter reads plain text only. Export the sheet to CSV first, either with Save As in Excel or with the XLSX to CSV tool, then paste or load the CSV here.

How do I turn the JSON back into CSV?

Paste the array into the JSON to CSV tool. It builds the header row from the object keys, so `[{"name":"John","age":"30"}]` becomes `name,age` followed by `John,30`.

All in Code & Data

JSON to CSV

Convert a JSON array of objects to CSV in your browser. Choose the delimiter, keep or drop the header row, with correct quoting. Nothing is uploaded.

Code & Data In your browser

YAML Formatter & Converter

Format YAML, convert YAML to JSON and JSON to YAML in your browser. Nothing is uploaded.

Code & Data In your browser

CSV to XLSX

Convert a UTF-8 CSV file to Excel XLSX with delimiter, sheet name and frozen-header controls.

Document Converters File on the server

XLSX to CSV

Export a selected XLSX worksheet to correctly quoted CSV with your chosen delimiter.

Document Converters File on the server

JSON Formatter

Format, validate and beautify JSON data privately in your browser.

Code & Data In your browser

CSV line builder from list

Build and validate a single CSV row locally with delimiter and quoting controls.

Text & Lists In your browser

What do you need?

Swipe up for the next one