By Docify

CSV to JSON in the Browser with Papa Parse

• 5 min read

To convert CSV to JSON in Docify, paste a table (or read a local .csv / .txt file) and click Convert. Papa Parse runs with header: true, skipEmptyLines: true, and dynamicTyping: true. The result is an array of objects, pretty-printed with 2-space JSON.stringify. A padded ID such as 007 becomes the number 7 (parseFloat). Quoted CSV "007" is still 7. A plus-prefixed cell such as +30 stays the string "+30" (Papa FLOAT accepts an optional minus, not a plus). -30 becomes -30. Plus is only legal in an exponent (1e+2). An incomplete exponent such as 1e or 1e+ stays the string "1e" or "1e+" (Papa FLOAT needs one or more digits after e or E). Write 1e+2 or 100 for the number. A hexadecimal prefix such as 0x1 stays the string "0x1" (Papa FLOAT has no 0x). Write 1 for the number. An underscore separator such as 1_000 stays the string "1_000" (Papa FLOAT has no underscore). Write 1000 for the number. A leading or trailing decimal such as .5 or 1. becomes 0.5 or 1 (Papa FLOAT allows those forms; JSON.parse rejects them). Quoted ".5" is still 0.5. A cell at ±2^53 such as 9007199254740992 stays the string "9007199254740992" (Papa testFloat is exclusive: floatValue > MIN_FLOAT && floatValue < MAX_FLOAT). 9007199254740991 becomes a number. A complete exponent such as 1e16 stays the string "1e16" because parseFloat of "1e16" is 10000000000000000, which is not < 2^53. Write 1e15 for the number 1000000000000000. A complete tiny exponent such as 1e-324 becomes the number 0 because parseFloat of "1e-324" is 0 (IEEE-754 underflow; Number.MIN_VALUE is 5e-324), and 0 is inside ±2^53. Write 5e-324 for Number.MIN_VALUE. A FLOAT cell with surrounding space such as 30 becomes 30 (FLOAT regex /^\s*…\s*$/). Quoted " 30 " is still 30. true stays a string. An unquoted both-side tab around 30 on a one-column header is auto-detected as a delimiter (TooManyFields); the page writes no JSON. A quoted tab-padded 30 stays one cell and becomes 30 (FLOAT \s includes tab). In a two-column comma table, an unquoted tab-padded 30 is also 30. A one-column table such as name then Ada is UndetectableDelimiter (average field count is 1, below 1.99) . Papa still defaults to comma and would return [{"name":"Ada"}], but Convert treats any result.errors as fatal and writes no JSON. Two-column n,x plus 30,foo succeeds. Duplicate headers are renamed so object keys are not overwritten: the first name stays name; a later name becomes name_1. name,name plus Ada,Bob becomes {"name":"Ada","name_1":"Bob"} and Convert writes that JSON. Quoted "name" / "name" is the same. name and Name are different keys. JSON.parse of {"name":"Ada","name":"Bob"} keeps the last value (RFC 8259 §4). A short data row such as name,age,city plus Ada,30 is TooFewFields (expected 3 fields but parsed 2). Papa still builds {"name":"Ada","age":30} and omits city, but Convert treats that FieldMismatch as fatal and writes no JSON. A trailing comma (Ada,30,) is three fields ({"name":"Ada","age":30,"city":null}) and Convert succeeds. A long row such as name,age plus Ada,30,extra is TooManyFields; Papa stores the extra cell on __parsed_extra as ["extra"]. An unclosed quote such as name,note plus Ada,"hello is MissingQuotes (Quoted field unterminated). Papa still builds {"name":"Ada","note":"hello"}, but Convert treats that Quotes error as fatal and writes no JSON. A closed Ada,"hello" succeeds. A trailing space after a closing quote such as Ada,"hello" plus a space is InvalidQuotes (Trailing quote on quoted field is malformed) plus MissingQuotes. Papa still builds {"name":"Ada","note":"hello\" "}, but Convert treats those Quotes errors as fatal and writes no JSON. A doubled quote inside a quoted field such as Ada,"hel""lo" is RFC 4180 §7 (the "" pair is one quote, ABNF 2DQUOTE). Convert writes {"name":"Ada","note":"hel\"lo"} and there is no Quotes error. A two-column semicolon table such as name;age then Ada;30 is auto-detected (guessDelimiter keeps a candidate when the average field count is greater than 1.99). Convert writes [{"name":"Ada","age":30}]. Papa's FLOAT test uses a decimal point, so 3,14 in that table stays the string "3,14". Write 3.14 for the number 3.14. Mixed comma and semicolon in the same table is UndetectableDelimiter; Convert writes no JSON. A full ISO timestamp such as 2026-09-18T12:00:00Z becomes 2026-09-18T12:00:00.000Z (Papa ISO_DATE, then Date.prototype.toJSON). A date-only cell stays a string. The strings true and TRUE become JSON true; title-case True stays a string. An empty cell, and a quoted empty "", become JSON null. A space-only cell and the word null stay strings. A blank line between Ada,30 and Bob,40 is skipped (skipEmptyLines: true); Convert writes both rows. A spaces-only row is UndetectableDelimiter plus TooFewFields; Convert writes no JSON. A comma-only row , is {"name":null,"age":null} and Convert succeeds. A two-column hash line such as # note,ignored is kept as data (comments defaults to false). Convert writes {"name":"# note","age":"ignored"} plus the Ada row. A one-field # comment row is UndetectableDelimiter plus TooFewFields; Convert writes no JSON. Nothing is uploaded.

Conversion runs after you click, not as a live preview. The CSV to JSON converter does not parse as you type and does not read Excel workbooks. Papa.unparse is unused on that page. The reverse is JSON to CSV (JSON.parse then Papa.unparse). Nested objects become JSON.stringify cells. IEEE-754 outputs such as 1e16 → 10000000000000000 are on Papa.unparse vs Papa.parse.

Buttons on the page

  • Convert — disabled while the CSV box is empty. Runs Papa.parse on that string. If the box is only whitespace, the page shows “Please enter CSV data” and does not write JSON.
  • Upload CSV — accepts .csv or .txt files. Reads the file content with FileReader.readAsText and fills the CSV input box. Click Convert after uploading to parse the table.
  • Download JSON — saves the JSON as converted.json with MIME type application/json. Disabled until there is valid output to download.
  • Load sample — fills the CSV input with a four-column example table so you can try the converter.
  • Clear — empties CSV, JSON, and the error. Disabled only when both boxes are already empty.

Sample table after Convert

Click the sample, then Convert. Ages become numbers because of dynamicTyping. The old “instant convert” example that showed "age": "30" was wrong for this page.

[
  {
    "name": "John Doe",
    "age": 30,
    "email": "john@example.com",
    "city": "New York"
  },
  {
    "name": "Jane Smith",
    "age": 25,
    "email": "jane@example.com",
    "city": "Los Angeles"
  },
  {
    "name": "Bob Johnson",
    "age": 35,
    "email": "bob@example.com",
    "city": "Chicago"
  }
]

Copy vs download

The JSON card has a Copy button that writes the same string to the clipboard. Both Copy and Download stay disabled until Convert succeeds. Pretty-print later in the JSON formatter if you need to minify or re-indent — this page always uses 2-space JSON.stringify.

Convert a CSV table

Paste or read a local file, click Convert, copy or download the objects. No upload.

Use CSV to JSON →

FAQ

How do I convert CSV to JSON?
Paste or upload your CSV file, then click Convert. The first row becomes object keys; subsequent rows become array elements.
Does this tool upload my data?
No. All parsing runs in your browser using Papa Parse. Your CSV data is never sent to a server.
Does it auto-detect delimiters?
Yes. Papa Parse detects commas, semicolons, tabs, and other common delimiters automatically.
How are numbers handled?
With dynamicTyping enabled, Papa Parse converts numeric-looking cells to JavaScript numbers whether they are quoted or not. CSV quotes only escape delimiters, quotes, and newlines; they do not keep a value as a string. Plus-prefixed values stay strings.
What if my CSV has duplicate column names?
Duplicates are renamed with suffixes: name, name_1, name_2, etc. to avoid overwriting object properties.

Related