How to convert CSV
- Paste your CSV into the editor or click Upload CSV to open a file.
- Make sure the first line holds the column names.
- Click Convert to JSON, Convert to XML or Convert to SQL.
- Copy or download the result from the right panel.
How your CSV is read
- The first row is the header. Each value in it becomes a field name.
- Every row after that becomes one record: one JSON object, one XML element or one row in the INSERT statement.
- A field that contains a comma must be wrapped in double quotes, as in
"Smith, John",Boston,42. - An empty field comes out as an empty string.
- Values stay text.
42becomes"42"in JSON, because a CSV file doesn't say which columns are numbers. - The separator must be a comma. Files that use semicolons need to be exported again with commas.
Example
name,city,age
"Smith, John",Boston,42
Ann,,7
converts to
[
{
"name": "Smith, John",
"city": "Boston",
"age": "42"
},
{
"name": "Ann",
"city": "",
"age": "7"
}
]
Generating SQL from CSV
Convert to SQL opens a small dialog where you enter the table name and choose PostgreSQL, MySQL, SQL Server or SQLite. You get a CREATE TABLE statement followed by an INSERT with one row per CSV line. Quotes inside values are escaped for you, so O'Brien becomes 'O''Brien', and table and column names are quoted the way the chosen database expects. All columns are created as VARCHAR(255), so adjust the types before you run the script against a real database.
Frequently asked questions
My file uses semicolons instead of commas. What can I do?
Spreadsheet programs in countries that use a comma as the decimal mark often save CSV with semicolons. Save the file again and choose comma as the separator, or replace the semicolons before converting.
How do I turn JSON back into CSV?
Open the JSON/XML formatter, paste your JSON, click Convert to CSV and then Export CSV to download the file. Nested objects are flattened into columns with dotted names such as address.city.
Why are my numbers in quotes in the JSON output?
CSV has no data types, so every value is read as text. If you need real numbers, change them in the JSON afterwards or cast them in your code.