How to Convert CSV to JSON: Headers and Delimiters
Last updated: · 3 min read
Tabular data is often exported as CSV, but web applications and APIs expect JSON. The CSV to JSON Converter uses the first row as field names and turns every data row into a JSON object. It follows RFC 4180, so it reads quoted fields, commas inside a field and line breaks inside a field correctly. You can choose a comma, semicolon or tab as the delimiter and decide whether values stay text or become numbers and booleans. The conversion runs in your browser.
Formula
1. The first line of the text is taken as the header and read as the list of field names. 2. Each line is split into fields according to the chosen delimiter; quoted fields are kept together. 3. Inside a quoted field, two consecutive double quotes are read as one double quote character. 4. Each header name becomes a key that is paired with the value in the same position, forming one object per row. 5. If the value type is automatic, numbers, true/false and null are converted to their types; if it is all text, every value stays a string.
This is not a mathematical formula but a parsing algorithm. The format follows the rules in RFC 4180. Every line after the header produces one object; extra fields are named kolon_N, where N is the column number.
What the inputs mean
- CSV
- The CSV text to convert. You can paste content exported from a spreadsheet. The first line must be the header row.
- Delimiter
- The character that separates fields: comma, semicolon or tab. Spreadsheets in locales that use commas for decimals often export with semicolons.
- Value types
- 'All text' turns every value into a quoted string; 'Automatic' converts numbers, true/false and null into their real types.
Worked example: Converting a semicolon-separated product list
- Input: the first line is the header sku;price, followed by the rows A1;12.5 and "Ink, blue";8. The delimiter is semicolon and the value type is automatic.
- Because "Ink, blue" is quoted, the comma inside it is not treated as a delimiter and the field stays one value.
- In automatic mode 12.5 and 8 become numbers, while A1 and Ink, blue remain text.
- Each data row becomes one object, so the array contains two items.
Result: The output is a JSON array of two objects with sku and price fields; the price values are unquoted numbers.
How to read the result
Automatic type conversion is useful for numerical analysis, but for fields such as postcodes or customer numbers, a leading zero can be lost when the value becomes a number. Choose 'All text' for those columns. Also make sure every row has the same number of fields as the header. This is general information.
Common mistakes
- Choosing the wrong delimiter: converting a semicolon file with the comma option produces a single-column result.
- Forgetting to close a quoted field; the converter reports the line where the quoted field was left open.
- Skipping the header row; the first line is always used as field names and is not read as data.
- Having more fields in a row than in the header; the extra fields are added with names such as kolon_3.
- Forgetting that with 'All text' selected, numbers are strings in the JSON and appear in quotation marks.
Frequently asked questions
What does RFC 4180 say about this conversion?
Fields are separated by the delimiter, fields containing commas or line breaks are wrapped in double quotes, and a double quote inside a quoted field is written twice. The converter applies these rules.
When should I choose a semicolon?
In locales where the decimal separator is a comma, Excel often saves CSV files with semicolons. Open the file and check which delimiter it uses.
Automatic or text values?
Use automatic values for calculations; for identifiers and codes, 'All text' is safer.
Is my CSV file sent to a server?
No. The conversion runs in your browser and the text is not sent to a server.
The result is not exact or binding and is for information only; it is not an official document and cannot be used in official procedures. Confirm it with the competent authority or a professional before acting; no liability is accepted for losses arising from its use.