⇄ Code & API Conversion

CSV to JSON & JSON to CSV Converter

Convert CSV to JSON and back. Auto-detects comma, semicolon, tab and pipe; keeps leading zeros; handles quotes, BOMs, ragged rows and duplicate headers; Excel-safe export.

Keeps leading zeros Auto-detect delimiter Excel BOM & injection check Files stay local

Loading CSV ⇄ JSON…

What this page sends

  • Your input: Files are read and converted in this tab (large ones in a Web Worker) and not sent to a server.
  • Share links: Share links put a Base64 copy of your input and output in the URL itself (after #d=). Anyone with the link can read it, so don't share a link that contains secrets.
  • Editor: On desktop screens the code editor (Monaco) is downloaded from cdn.jsdelivr.net; phones get a built-in lightweight editor instead.
  • Page load: Loading the page requests HTML, scripts and images from ByteKiln, fonts from Google Fonts, and sends Google Analytics page views, tool-usage events and catalog interactions (tool/category IDs, result status and whether a click followed search — never your input, output or search terms). Privacy & sharing

How the CSV to JSON & JSON to CSV Converter Works

CSV looks like the simplest format there is, which is why converters get it wrong so often: leading zeros vanish from ZIP codes, a semicolon-separated export from European Excel becomes one giant column, a quoted comma splits a field in two, and an invisible byte order mark turns the first header into "\uFEFFname". This converter goes both ways. CSV to JSON parses with Papa Parse (RFC 4180 quoting, embedded newlines and doubled quotes), detects the delimiter, strips a BOM, renames duplicate headers instead of overwriting them, reports ragged rows with line numbers, and only converts numbers and booleans when that changes nothing. Output an array of objects, an array of arrays, or objects keyed by a column, optionally nesting dotted headers like address.city. JSON to CSV takes an array of objects with any mix of keys, flattens nested objects, handles arrays as JSON text or indexed columns, lets you choose the column order, and warns about cells that spreadsheets would run as formulas. A "For Excel" option adds the BOM and CRLF line endings Excel expects.

Parsing CSV

Papa Parse handles quoted fields containing delimiters, doubled quotes ("") and line breaks. Blank lines are skipped. An unterminated quote is reported with its line number, since it usually swallows the rest of the file. Line numbers refer to the original text, so a row with an embedded newline still points to the right place.

Type inference

Inference is off by default: every value stays a string. When on, it works per column: true/false and null become JSON literals, and a column becomes numbers only if every non-empty value is a plain decimal that converts back without change — no leading zeros, no plus sign, no exponent, within JavaScript's exact integer range (2^53).

Headers and shapes

Empty headers become column1, column2…; duplicates become name_2, name_3 with a warning. "Keyed by column" builds an object whose keys are a column's values and warns if they aren't unique. "Nest dotted headers" turns address.city into { "address": { "city": … } }.

Writing CSV

Columns are the union of all object keys in first-seen order, or the order you give. Fields are quoted only when needed (delimiter, quote, newline, or leading/trailing space) unless you quote everything. Line endings are CRLF as RFC 4180 specifies, or LF.

Limitations

  • It reads CSV and TSV text, not Excel .xlsx files — export from Excel as CSV first.
  • Type inference is off by default and, when on, works per column; dates stay strings.
  • Files are held in memory; very large files (hundreds of MB) may exhaust the tab even though parsing runs in a Web Worker.
  • Nesting from dotted headers is one-way convention, not a schema; arrays inside CSV cells aren't split.

FAQ

Short answers for the things developers usually ask before trusting a tool.

Is my file uploaded?

No. Files are read and converted in your browser; large files are converted in a background Web Worker on your device. Nothing is sent to a server. If you press Share, the link itself carries a readable copy of your input, so don't share links that contain secrets.

Why did my ZIP codes or phone numbers lose their leading zeros?

Because a converter turned "02134" into the number 2134. This tool keeps every value as a string by default. With "Detect numbers & booleans" on, a column only becomes numbers when every value converts without changing — so a ZIP column with 02134 stays text, and so do +44 phone numbers and IDs longer than 15 digits.

My CSV uses semicolons. Will it work?

Yes. Excel in many European locales saves "CSV" with semicolons because the comma is the decimal separator. The delimiter is detected automatically (comma, semicolon, tab or pipe), and you can override it.

What is CSV injection?

A cell that starts with =, +, - or @ can be run as a formula when the CSV is opened in Excel or Google Sheets — for example =HYPERLINK(...) pointing to a malicious site. When exporting JSON to CSV, the tool counts such cells and can prefix them with an apostrophe, the OWASP-recommended mitigation. Plain negative numbers like -5 are not flagged.

Why does Excel show 1.23E+15 instead of my ID?

Excel converts long numbers to floating point when it opens a CSV and only keeps 15 significant digits, so long IDs and card-like numbers are displayed in scientific notation and can lose digits. The CSV itself is fine. Import the file with Data → From Text/CSV and set that column to Text, or keep such values quoted and prefixed. The "For Excel" option also adds a UTF-8 BOM so accented characters display correctly.

What happens with rows that have a different number of fields?

Nothing is dropped. Missing fields are empty and extra fields are kept under _extra1, _extra2… The tool lists each ragged row with its line number, which usually points to an unquoted comma or a stray quote.

Related tools

Useful follow-ups when one conversion usually turns into three more.