CSV to JSON Converter - Free Online File Converter Tool
Convert CSV files to JSON or JSON files to CSV for free. All processing happens in your browser, so your data never leaves your device or reaches a server.
CSV/JSON File Converter
Convert between CSV and JSON formats with ease. Upload your file, preview the data, and download the converted result.
CSV to JSON Converter
JSON to CSV Converter
Documentation
What is a CSV to JSON converter?
A CSV to JSON converter is a tool that changes data from CSV (Comma-Separated Values) format into JSON (JavaScript Object Notation) format, or the other way around. This converter runs entirely inside the web browser. It never sends the uploaded file to a server, so the data stays on the user's device.
CSV is a plain-text format used to store tables, such as spreadsheets exported from Excel or Google Sheets. JSON is a text format built from key-value pairs, widely used to move data between web applications and APIs. Because the two formats organize data differently, converting between them requires a defined set of rules, described below.
How to convert CSV to JSON
- Click "Upload CSV File" and choose a
.csvfile from the device. - The tool shows a preview of the raw file content.
- Click "Convert to JSON". The tool reads the first line as column headers and turns every other line into one JSON object.
- The result appears in the output preview, formatted with indentation.
- Click "Download JSON" to save it as a
.jsonfile, or "Copy JSON" to copy the text.
How to convert JSON to CSV
- Click "Upload JSON File" and choose a
.jsonfile. The file must contain a JSON array of objects, for example[{"Name":"Ann"},{"Name":"Bo"}]. - The tool shows a preview of the raw JSON text.
- Click "Convert to CSV". The tool collects every key used across all the objects and turns each one into a column.
- The result appears in the output preview as CSV text.
- Click "Download CSV" to save it as a
.csvfile, or "Copy CSV" to copy the text.
There are no upload limits enforced by a server, because none of the data leaves the browser. A very large file can still slow the browser tab down, since the whole file is held in memory while it converts.
CSV to JSON conversion rules
The converter reads the first row of the file as column names. Each following row becomes one JSON object, with the column names as keys. A row with more values than there are headers gets extra keys named by their absolute position in the row, so with 3 headers, a fourth value is keyed field_4, a fifth field_5, and so on, meaning no data is dropped. A row with fewer values gets empty strings for the missing keys. If two headers have the same name, the second one is renamed with a suffix, so a, a becomes the keys a and a_2.
The converter follows the CSV rules defined in RFC 4180, the technical standard for the format. A comma inside a field is only treated as a value inside that field, not a column break, if the field is wrapped in double quotes, for example "Smith, John". A line break inside quotes is kept as part of the value rather than treated as a new row. Two double quotes inside a quoted field represent one literal quote character.
Only commas are recognized as the column separator; the tool does not detect or support semicolons, tabs, or other delimiters.
Each value is checked and converted to a type:
- A value written as a plain number, such as
42or-3.5, becomes a JSON number. - The text
trueorfalse(in any letter case) becomes a JSON boolean. - Anything else stays a JSON string, including empty cells, which become empty strings.
- A number with a leading zero, such as
00512, stays a string, because the leading zero is often meaningful, as in a ZIP code or ID number. - A whole number too large to store exactly as a JavaScript number (larger than 9,007,199,254,740,991) stays a string, so no digits are lost.
- A value the file already wrapped in quotes is always kept as a string, even if it looks like a number, since quoting is treated as the author marking it as text.
Blank lines in the file are skipped and do not produce empty objects.
JSON to CSV conversion rules
The converter looks at every object in the array and collects the full set of keys used across all of them. Those keys become the CSV column headers, in the order first seen. If one object is missing a key that another object has, its cell is left empty rather than causing an error.
JSON to CSV does not flatten nested objects into separate columns. A value that is itself an object is converted to plain text and shows up as the literal text [object Object], which loses the original structure. A value that is an array is converted to a comma-separated list of its elements as plain text. To avoid losing data, flatten any nested JSON manually before conversion, so each value is a plain string, number, or boolean.
A cell value that contains a comma, a quote mark, or a line break is wrapped in double quotes in the output, and any quote mark inside it is doubled, matching the CSV escaping rule above.
The input JSON must be an array of objects. If it is not an array, or the array is empty, the tool shows an error instead of guessing at a conversion.
Example
Starting CSV file:
1Name,Age,Member
2Ann Lee,29,true
3"Bo, Jr.",7,false
4Converting it to JSON produces:
1[
2 {
3 "Name": "Ann Lee",
4 "Age": 29,
5 "Member": true
6 },
7 {
8 "Name": "Bo, Jr.",
9 "Age": 7,
10 "Member": false
11 }
12]
13Note that "Bo, Jr." kept its comma because the field was quoted in the source file, and Age and Member became a number and a boolean.
Converting that same JSON back to CSV, with an added row where Age is missing, produces:
1Name,Age,Member
2Ann Lee,29,true
3"Bo, Jr.",7,false
4Cy Tan,,true
5The missing Age value becomes an empty cell, and the comma in "Bo, Jr." causes the field to be quoted again on the way out.
Common uses
- Data analysis: turning a CSV export from a spreadsheet or analytics tool into JSON so it can be processed with JavaScript, then converting the results back to CSV for a report.
- API testing: a developer building an API that accepts CSV uploads can convert sample files to JSON to check that a parser produces the expected objects.
- Data migration: moving records from a system that exports CSV to a system that only accepts JSON, or the reverse.
- Quick inspection: turning a JSON file into a table-like CSV to read it more easily, or the other way around.
Programming libraries offer the same conversion for larger or repeated jobs, such as the csv and json modules in Python, or pandas. Command-line tools such as csvkit and jq handle conversion and filtering from a terminal. Those options suit batch processing; this browser tool suits a one-off file without installing anything.
Frequently asked questions
Is the uploaded file sent to a server? No. The conversion runs in JavaScript inside the browser tab. The file is read from the local device and never transmitted.
Does the converter support delimiters other than a comma, such as a semicolon or tab? No. The current version only reads comma-separated values. A file using a different delimiter needs to be converted to comma-separated form first, for example by replacing the delimiter in a text editor.
Why did a number like 00512 stay a text string in the JSON output?
Leading zeros are usually meaningful, as in a ZIP code, so the converter keeps that value as a string rather than turning it into the number 512, which would drop the zero.
What happens if I convert JSON that contains nested objects?
Each nested object becomes the text [object Object] in its CSV cell, and the original structure is lost. Flatten nested data into plain fields before converting.
What if my JSON is not an array of objects?
The tool shows an error. The input must be a JSON array, and each item should be an object, for example [{"a":1},{"a":2}].
Does the first row of a CSV file always have to be a header row? Yes. The converter always treats the first row as column names. A file without a header row will have its first data row misread as headers.
References
- Shafranovich, Y. "Common Format and MIME Type for Comma-Separated Values (CSV) Files." RFC 4180, IETF, October 2005. https://www.rfc-editor.org/rfc/rfc4180
- Bray, T., ed. "The JavaScript Object Notation (JSON) Data Interchange Format." RFC 8259, IETF, December 2017. https://www.rfc-editor.org/rfc/rfc8259
- "Working with JSON." MDN Web Docs, Mozilla. https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Scripting/JSON