Contact

CSV to JSON

CSV
Character: 0/200000Word: 0Line: 0Sentence: 0
JSON
Character: 0Word: 0Line: 0Sentence: 0

Found this tool useful? Share it:

Share
Share
Share
Share

What this CSV to JSON converter does

It reads comma-separated (or semicolon-, pipe- or tab-separated) text and turns every row into a JSON object, using the first row as the key names. It follows the common RFC 4180 quoting rules, so fields that contain commas, line breaks or doubled quotes are read correctly. Conversion happens in your browser as you type or change an option.

How to convert CSV to JSON

  1. Paste your CSV into the input box, or use Upload to read a .csv, .xlsx, .txt or .docx file.
  2. Check the delimiter. Spreadsheets in many European locales export semicolons instead of commas.
  3. Choose the options you need (listed below) and watch the JSON update.
  4. Copy the JSON, or download it as converted.json.

Example

CSV input
name,age,note
Ann,30,"likes, commas"
Bob,25,"say ""hi"""
JSON output (Parse numbers on)
[
  {
    "name": "Ann",
    "age": 30,
    "note": "likes, commas"
  },
  {
    "name": "Bob",
    "age": 25,
    "note": "say \"hi\""
  }
]

What each option does

CSV to JSON converter options
OptionEffect
DelimiterThe separator between values: one character, a comma by default. Type ; or | , or paste a tab character for tab-separated data.
Output: ArrayAn array of objects, one per row.
Output: HashOne object keyed by the first column. If two rows share a key the later row replaces the earlier one, and a blank key falls back to the row's position in the data, counting from 0.
First row contains headersOn: the first row provides the key names. Off: keys are column_1, column_2 and so on, and the first row is treated as data.
Parse numbersPlain decimals such as 42, -4.5 and 0.25 become JSON numbers. Anything else stays text: values with leading zeros (01234), integers too large to be stored exactly, 1e5, +5, .5 and 1,000.
Parse JSONCells that start with { or [ are parsed as JSON, and the lowercase words true, false and null become booleans and null (TRUE stays text). A cell that fails to parse stays text.
TransposeSwaps rows and columns before converting.
MinifyWrites the JSON on one line instead of indenting it by two spaces.
Lowercase keyConverts the key names to lowercase.

How edge cases are handled

How unusual CSV input is converted
InputResult
Quoted field with a comma, line break or doubled quoteRead as one value, with the quotes removed and doubled quotes turned into single ones.
Empty header cellThe key becomes column_N, where N is the column number.
Repeated header namesLater copies get _2, _3 and so on (name, name_2, name_3) so no column overwrites another.
Row with more cells than headersThe extra cells are kept as column_N instead of being dropped.
Row with fewer cells than headersThe missing values are empty strings.
Completely empty linesSkipped.
Spaces around a valueRemoved. Spaces inside a quoted value are kept.
Windows (CRLF) or Unix (LF) line endings, and a byte order markHandled.

Common problems

  • Everything is one column: the delimiter does not match the file. Try a semicolon or tab.
  • Numbers come out as text: switch on Parse numbers. Leave it off for IDs, zip codes and phone numbers so leading zeros are not lost.
  • Keys look wrong: the first row is probably data, not headers. Switch off First row contains headers.
  • Values with commas break across columns: make sure those fields are wrapped in double quotes in the source file.

Privacy

Text you paste is converted in your browser and is not sent to our servers. If you use the Upload button, the file is sent to our server to be read and is not stored. See the Privacy Policy.

See also

Frequently asked questions

Does it handle commas, quotes and line breaks inside a field?
Yes. A field wrapped in double quotes can contain the delimiter, a line break or doubled quotes (""), following the common RFC 4180 convention.
Why are all my values strings?
CSV has no types, so every value is text unless you switch on Parse numbers. That option converts plain decimals only, and deliberately leaves values with leading zeros as text.
Why does 007 or 01234 stay a string with Parse numbers on?
Leading zeros usually mean an ID, zip code or phone number. Converting them to numbers would drop the zeros, so they are kept as text. Integers too large to be stored exactly are also kept as text for the same reason.
What happens to duplicate or blank column names?
Blank headers become column_N and repeated names get _2, _3 and so on, so no column silently replaces another.
What if a row has too many or too few values?
Extra values are kept as column_N keys. Missing values become empty strings.
Can I use a semicolon or tab instead of a comma?
Yes. Type the character in the Delimiter box, or paste a tab character for tab-separated data. Excel in many European locales exports semicolons.
What is the Hash output?
Instead of an array, you get one object whose keys are the values in the first column. If two rows share a key the later row wins.
Can I convert JSON back to CSV?
Yes, with the JSON to CSV Converter, which is listed under Related tools.
Is my data uploaded?
Pasted text is converted in your browser. Only the Upload button sends a file to our server, where it is read and not stored.