JSON Tools
CSV to JSON Converter
Convert CSV rows into a JSON array of objects in your browser.
Input stays in this browser while you use the tool.
About this tool
The CSV to JSON Converter turns a CSV table into JSON. CSV (comma-separated values) is the plain-text format that spreadsheets such as Excel and Google Sheets export, and that many databases and reporting tools use. JSON is the format that web applications and APIs read. The converter reads the first line of your CSV as the column names and turns every following line into an object, so the result is a JSON array of objects, one object per row.
The two formats are built for different jobs. A CSV file is flat and compact: every line is a row, and the values in a row are separated by commas. JSON can hold named fields, nested data and several value types, which is what code usually needs. Converting a spreadsheet export to JSON is therefore the usual first step when you want to load a table into a JavaScript application, seed a database, build a mock API or send a list of records to a service.
The conversion follows the common CSV rules. A value that contains a comma, a quotation mark or a line break is wrapped in double quotes, and a quotation mark inside such a value is written twice. CSV has no data types, so every value is text in the file. Whether a value such as 9.99 stays a string or becomes a JSON number depends on the converter, and it is worth checking the output, especially for IDs, ZIP codes and phone numbers.
The conversion runs in your browser, so your data is processed on your own device and is not sent to the BitToolsKit server.
Use cases
- Turn a spreadsheet export into JSON for a frontend. Export a sheet as CSV, convert it and use the array directly in a React, Vue or plain JavaScript project.
- Build mock data for an API or a test. Prepare sample records in a spreadsheet, where they are easy to edit, and convert them into fixtures or a mock response.
- Seed or import into a database. Many document databases and import tools accept a JSON array, and a CSV export from another system is the usual starting point.
- Prepare data for an API request. Convert a list of contacts, products or orders to JSON and send it as the body of a bulk request.
- Check the shape of a CSV file. Seeing each row as an object makes problems visible, such as shifted columns, empty values and misspelled headers.
- Migrate configuration and lookup tables. Country lists, price tables and translation sheets are often maintained as CSV and consumed as JSON.
- Clean up a report before analysis. Convert it, run the result through the JSON Validator and format it with the JSON Formatter to read it comfortably.
- Learn how the formats map to each other. Change one cell and watch how the matching field in the JSON changes.
How to use
- Export your table as CSV from your spreadsheet. In Excel and Google Sheets, choose the UTF-8 version of CSV, so that accented letters and other alphabets survive.
- Paste the CSV text into the Input box. The first line must be the header row with the column names, because these names become the keys of the JSON objects.
- If the tool offers a delimiter option, choose the separator that your file uses: a comma, a semicolon or a tab. Some spreadsheet programs use a semicolon, depending on the regional settings of the computer.
- Click Run tool.
- Read the JSON in the Output box. Check the keys, the empty values and any column that holds numbers, IDs or dates.
- If a message appears or the result looks wrong, compare it with the common errors below and run the tool again.
- Click Copy output to copy the JSON, Download to save it as a file, or Clear to start again.
To check or read the result, paste it into the JSON Validator or the JSON Formatter. To go the other way, use the JSON to CSV Converter.
Examples
Example 1: A simple table
Input (CSV): id,name,city 1,Ada,London 2,Bob,Paris
What a converter produces (JSON):
[{"id":"1","name":"Ada","city":"London"},{"id":"2","name":"Bob","city":"Paris"}]
The header row supplies the keys, and each following row becomes one object. Some converters write the id values as numbers, as in "id":1.Example 2: A comma and quotation marks inside a value
Input (CSV): name,note "Smith, John","He said ""hi"""
What a converter produces (JSON):
[{"name":"Smith, John","note":"He said \"hi\""}]
The quotes in the CSV protect the comma, and the doubled quotation marks become one escaped quotation mark in JSON.Example 3: Empty cells
Input (CSV): a,b,c 1,,3
What a converter produces (JSON):
[{"a":"1","b":"","c":"3"}]
An empty cell usually becomes an empty string. Some converters write null instead.Example 4: A semicolon-separated file
Input (CSV): id;name 1;Ada
Read with the right delimiter (semicolon):
[{"id":"1","name":"Ada"}]
Read with the wrong delimiter (comma):
[{"id;name":"1;Ada"}]
If the result has a single key that contains your separator, the delimiter is wrong.Example 5: Leading zeros and big numbers
Input (CSV): zip,account 00123,12345678901234567890
As text (safe):
[{"zip":"00123","account":"12345678901234567890"}]
As numbers (risky):
The ZIP code 00123 becomes 123, and JavaScript reads the long number as 12345678901234567000. Keep identifiers as strings.Example 6: Two columns with the same name
Input (CSV): a,a,b 1,2,3
What a converter produces (JSON):
[{"a":"2","b":"3"}]
An object cannot have the same key twice, so the later column replaces the earlier one and the value 1 is lost. Some tools rename the second column. Give every column a unique name before you convert.Example 7: An invisible character at the start of the file
Input (CSV): A file saved with a byte order mark (BOM), then: id,name 1,Ada
What a converter can produce: The first key looks like id but starts with an invisible character, so code that reads the id key finds nothing. Save the file as UTF-8 without a BOM, or retype the first characters of the header.
Common errors
The whole row ends up in one key, such as "id;name"
The file uses a different separator than the converter expects. Many spreadsheet programs write a semicolon in regions where the comma is the decimal mark, and some files use a tab. Choose the matching delimiter, or replace the separator with a comma.
The first data row became the keys
The converter always reads the first line as the header. If your file has no header row, add one at the top with a name for every column.
An unclosed quotation mark swallows the following lines
A value that starts with a double quote must end with one. A missing closing quote makes the parser read on, often through several lines, so you get one huge value or missing rows. Close the quote, and write a quotation mark inside a value as two quotation marks.
Columns are shifted because of a comma inside a value
A value such as Smith, John without quotes is split into two cells, and everything after it moves one column to the right. Wrap values that contain a comma in double quotes, or export the file again from the spreadsheet, which adds them for you.
Numbers lose zeros or precision
CSV has no types, and turning text into numbers changes it: the ZIP code 00123 becomes 123, and an integer above 9007199254740991 loses digits in JavaScript. Keep identifiers, phone numbers, ZIP codes and long numbers as strings, and convert only real quantities.
Empty cells appear as empty strings, not null
CSV cannot express the difference between an empty value and a missing one. If your code needs null, convert empty strings after the conversion, or check the output option of the tool.
Rows have a different number of values than the header
A row with fewer values leaves some keys without a value, and a row with more values has extra data that does not belong to any key. Make sure that every row has as many cells as the header, and look for stray commas.
Two columns have the same name, or a name is empty
JSON objects cannot repeat a key, so the later column replaces the earlier one and data is lost. Rename the columns so that every name is unique and not empty.
Accented letters look garbled, or the first key is strange
The file was saved in another encoding than UTF-8, or with a byte order mark. In Excel, choose CSV UTF-8 when you save. If the first key looks right but cannot be found, an invisible character at the start of the file is the cause.
Keys or values contain extra spaces
Spaces after the commas become part of the values and of the key names, so a header written as name, city gives a key called space city. Remove the spaces in the spreadsheet or in the CSV text.
Frequently asked questions
What is CSV?
CSV stands for comma-separated values. It is a plain-text table in which every line is a row and the values in a row are separated by commas. Spreadsheets, databases and many reporting tools can export and import it.
What JSON do I get from a CSV file?
Usually an array of objects. The first line supplies the keys, and every following line becomes one object. Some tools can also produce an array of arrays, where the first array holds the column names.
Are numbers and booleans converted?
A CSV file stores only text, so a converter either keeps every value as a string or guesses types. Check the output for columns with numbers, true and false values, and especially for identifiers such as ZIP codes, where a number would remove leading zeros.
Can the converter handle commas, quotation marks and line breaks inside values?
Yes, if the CSV follows the usual rules: a value that contains one of them is wrapped in double quotes, and a quotation mark inside it is written twice. A value in quotes can even run over several lines.
Which delimiters are supported?
The comma is the standard. Semicolon and tab are common in files from spreadsheet programs with other regional settings. If the whole row appears as one value, the delimiter does not match your file.
Does my CSV need a header row?
Yes. The first line is used for the names of the keys. Add a header row if your file has none, and give every column a unique name.
How are empty cells converted?
Usually to an empty string. A CSV file cannot tell an empty value from a missing one, so convert empty strings to null in your code if you need that.
Can I convert a large CSV file?
Very large inputs can be slow, because the conversion happens in your browser. For files of many megabytes, a script or a command-line tool is a better choice.
How do I convert JSON back to CSV?
Use the JSON to CSV Converter. It works best with an array of objects that have the same flat keys. Nested objects need to be flattened first, because CSV has no nesting.
Is my data uploaded to a server?
No. The tool runs in your browser and works on your device. As a general habit, avoid pasting passwords, API keys or private tokens into any online tool.