Toolstia / CSV to JSON converter

CSV to JSON and JSON to CSV converter

Spreadsheets and APIs rarely speak the same format, and this converter bridges them in both directions. Paste CSV and you get a JSON array, one object per row, with the header row supplying the key names. Paste a JSON array of objects, or of arrays, and you get a CSV table with a header line built from the keys.

It reads real-world CSV rather than idealized samples: quoted fields, commas and line breaks inside quotes, doubled quotes, and files separated by semicolons, tabs or pipes. Settings let you treat the first row as data, keep every value as text, or pick the separator by hand. You can copy the result or download it as data.json or data.csv.

Options

Everything is converted in your browser. Values with leading zeros, such as 007, stay as text.

How it works

  1. Choose the direction.
  2. Paste your data, or press Use sample.
  3. Copy the result or download it as a file.

CSV to JSON

The first row becomes the keys, and each later row becomes an object. The separator is detected automatically, or you can choose it. Numbers and true/false can be turned into real values. Values with leading zeros, such as 007 or a phone number, stay as text so nothing is lost.

JSON to CSV

Give it an array of objects. The columns are every key found in any object, so rows with missing keys get empty cells. Nested objects and arrays are written as JSON text inside the cell.

Quotes and special characters

Values that contain the separator, a quote or a line break are wrapped in quotes, and quotes inside them are doubled, which is what Excel and Google Sheets expect.

Excel files

This tool reads text. To use an Excel file, save it as CSV first (File, then Save As, then CSV).

A semicolon file, converted

Given the semicolon-separated text id;name;zip, then 1;"Ann; Lee";00123, then 2;Bo;4500, then 3;Cy;true, the tool detects the semicolon from the first line and returns three objects. The first has id 1, name Ann; Lee and zip "00123", the second has zip 4500 as a number, and the third has zip true as a boolean.

Notice that the semicolon inside the quotes stayed in the name, and the leading zeros survived because 00123 is not converted to a number. Mixed results like the last row show why you should review the types if a column has inconsistent values.

Exactly which values become numbers

With the number option on, a value becomes a number only if it looks like a plain decimal: an optional minus sign, digits without a leading zero, and an optional fractional part. So 4500 and -0.5 convert, while 00123, .5, +3 and 1e3 stay as text. The words true and false become booleans.

One side effect is that 2.50 becomes 2.5, because JSON numbers do not preserve trailing zeros. If a column holds prices or version numbers where the exact text matters, turn the option off to keep every value as a string.

Header, duplicates and short rows

Keys come from the first row with surrounding spaces trimmed, and an empty header cell is named column_2, column_3 and so on by its position. If two columns share a name, the later one overwrites the earlier one in each object, so rename duplicates before converting.

A row with fewer cells than the header gets empty strings for the missing ones, and cells beyond the header width are ignored. Turn off the header option and the output becomes an array of arrays, with no keys at all.

Going from JSON to CSV

The columns are the union of every key, listed in the order they first appear, so an object that lacks a key simply gets an empty cell. Objects and arrays inside a value are written as JSON text in the cell, quoted as needed. Null becomes an empty cell. If the input is an array of arrays, each inner array becomes a row with no header.

Cells containing the separator, a quote, a line break, or leading or trailing spaces are wrapped in quotes with inner quotes doubled. The pipe, semicolon and tab choices apply to the output as well.

Opening the result in Excel

The CSV download starts with a byte order mark so that Excel recognizes UTF-8 and shows Bangla, accented letters and emoji correctly. The copy button gives the plain text without that mark.

A caution for spreadsheets: a cell that starts with an equals sign, plus, minus or at sign may be treated as a formula when opened, and this tool does not alter such values. Check data from untrusted sources before you open it in a spreadsheet. Also, an unquoted number written with a thousands comma, such as 1,000, is split into two cells.

Questions

Is my data uploaded?

No. It is converted in your browser.

Why is a number still shown with quotes?

Values with leading zeros, spaces or letters are kept as text on purpose.

Does it work with semicolons?

Yes. Many European spreadsheets use semicolons, and the tool detects them.

How large a file can it handle?

Several megabytes is fine on most computers. Very large files are better handled with a spreadsheet or a script.

Can it convert nested JSON into several columns?

No. Nested objects and arrays are kept whole as JSON text inside one cell. Flatten the data first if you need separate columns.

What happens if my JSON is an object instead of an array?

You get an error asking for an array. Wrap the object in square brackets to treat it as a single row.

Why is my date column unchanged?

Dates are not interpreted. They stay as the text you supplied, which is usually what you want for exact formats.

How are empty cells handled in CSV to JSON?

They become empty strings, not null. Replace them afterward if your application needs null.

Does the Swap button lose data?

It moves the current result into the input and flips the direction, which works well for round trips, but number conversion and key order can change the text slightly.