HomeFormattersDataCSV to JSON Converter

CSV to JSON Converter

Data

Convert CSV data to formatted JSON instantly. Handles quoted fields, custom delimiters, and header rows. Runs entirely in your browser — nothing is uploaded.

What is a CSV→JSON?

The CSV to JSON Formatter converts comma-separated values (or any delimiter-separated tabular data) into a formatted JSON array of objects, making the data immediately usable in JavaScript applications, REST APIs, MongoDB imports, and any other tool that works with JSON rather than flat text files.

CSV is the most common format for tabular data exports — from Excel spreadsheets, Google Sheets, database exports, CRM downloads, and report generators. But CSV has significant limitations for modern development: it has no type information, no nested structure, and no standard way to represent null values. When you need to process the data in JavaScript, load it into a document database, or pass it to an API, you need JSON.

The conversion is straightforward conceptually — each row becomes an object, each header becomes a key — but the implementation requires a proper CSV parser. A naive split(',') breaks immediately on any value that contains a comma inside quotation marks, such as "Mumbai, Maharashtra". The CSV to JSON Formatter uses an RFC 4180-compliant parser that handles all standard CSV edge cases:

  • Quoted fields containing the delimiter character: "value,with,commas"
  • Escaped quotes inside quoted fields: "He said ""hello"""
  • Values containing newlines inside quotes

All conversion runs entirely in your browser — no CSV data is uploaded to any server. This is particularly important for CSV files that contain personal information, financial data, or internal business records. Use the JSON Formatter to inspect and pretty-print the JSON output, or the XML Formatter if your target format is XML rather than JSON.

How to use this CSV→JSON calculator

  1. Paste your CSV data into the CSV Data input box — include the header row if your data has one.
  2. Select the Delimiter from the dropdown that matches your data: Comma, Semicolon, Tab, or Pipe.
  3. Toggle First row is a header on (for labelled output as an array of objects) or off (for a raw array of arrays).
  4. Choose a JSON Indent style: 2 spaces, 4 spaces, or Minified.
  5. The JSON Output updates instantly as you change any option.
  6. Click Copy to copy the JSON to your clipboard.

Formula & Methodology

CSV parsing (RFC 4180-compliant):

Each row is parsed character by character. When a field starts with ", the parser reads until a closing " that is not followed by another " (double-quote escape). Everything inside the quotes — including delimiter characters and newlines — is treated as part of the field value. Unquoted fields are read until the next delimiter or end of line.

Object construction:

When header mode is enabled, the first row's fields are used as keys. For each subsequent row, the parser creates an object by zipping the keys array with the row's values array. Rows shorter than the header produce objects with "" for missing values; extra columns are dropped.

When header mode is disabled, each row is returned as a plain string array.

JSON serialisation:

The resulting array is serialised with JSON.stringify(rows, null, indentSize), where indentSize is 2, 4, or undefined (minified).

Before (CSV):
name,age,city Alice,30,"Mumbai, Maharashtra" Bob,25,Delhi

After (JSON, 2-space indent):
json [   {     "name": "Alice",     "age": "30",     "city": "Mumbai, Maharashtra"   },   {     "name": "Bob",     "age": "25",     "city": "Delhi"   } ] 
Frequently Asked Questions
What is CSV to JSON conversion?
CSV to JSON conversion transforms a tabular CSV (comma-separated values) file into a JSON array of objects, where each row becomes an object and each column header becomes a key. For example, a CSV row `Alice,30,Mumbai` with headers `name,age,city` becomes `{"name":"Alice","age":"30","city":"Mumbai"}`. This makes the data usable in JavaScript applications, REST APIs, and tools that consume JSON rather than CSV.
What delimiters does this converter support?
The converter supports four common delimiters: comma (`,`), semicolon (`;`), tab (`\t`), and pipe (`|`). Semicolons are common in European CSV exports from Excel, which uses semicolons by default in locales where commas are the decimal separator. Tab-separated values (TSV) are common exports from Google Sheets and LibreOffice Calc. Select the appropriate delimiter from the Delimiter dropdown before converting.
How does the converter handle quoted fields containing commas?
The converter uses a full RFC 4180-compliant CSV row parser that correctly handles quoted fields. A value like `"Mumbai, Maharashtra"` is treated as a single field containing the comma, not as two separate fields. Double-quoted commas, semicolons, and newlines within quoted fields are all handled correctly. This is important because a naive `split(',')` approach breaks on any value that contains the delimiter character.
What does 'First row is a header' do?
When this option is enabled (the default), the first row of the CSV is used as the key names for the JSON objects — each column header becomes a property name. The output is an array of objects. When disabled, the first row is treated as data and the output is an array of arrays (each row becomes a flat array of string values), which is useful when the CSV has no header row or when you want to preserve the raw row structure.
Can I convert TSV (tab-separated) files?
Yes. Select 'Tab (\t)' from the Delimiter dropdown and paste your TSV data. Tab-separated files are a common export format from Google Sheets, Microsoft Excel (when saving as .txt or .tsv), and many database export tools. The converter handles quoted tab-delimited fields using the same RFC 4180-compliant parser as comma-separated data.
Are all values in the JSON output strings?
Yes. The converter preserves all values as strings in the JSON output, regardless of whether they look like numbers, booleans, or dates. This is intentional — the converter cannot reliably determine the intended type of a field without a schema. If you need numeric fields, apply a post-processing step in your code (e.g. `Number(row.age)`) after parsing the JSON.
How do I convert CSV to JSON?
Paste your CSV data into the CSV Data input box, ensure the Delimiter matches your file's separator, check whether the first row is a header, choose the JSON indentation style, and the JSON output appears instantly. Click Copy to copy the result to your clipboard.
Is my data uploaded anywhere?
No. The CSV to JSON conversion runs entirely in your browser using JavaScript. The CSV data you paste — which may include names, email addresses, financial figures, or other sensitive information — is never sent to any server, stored, or logged. Your data stays in your browser tab.
Does this work offline?
Yes — once the page has loaded, the converter runs without a network connection. The CSV parser and JSON serialiser are pure JavaScript that executes locally.
Can I convert large CSV files?
The converter is limited only by your browser's available memory. Files with a few thousand rows and tens of columns convert in under a second. Very large files (hundreds of thousands of rows) may cause the browser to pause briefly while processing. For large-scale CSV-to-JSON conversion in production, use a command-line tool or a Node.js script with a streaming CSV parser.
What happens if my CSV has inconsistent column counts?
The converter handles rows with fewer columns than the header by leaving those keys with empty string values. Rows with more columns than the header include only the columns that have a corresponding header key — extra values are discarded. No error is thrown for inconsistent column counts; the converter processes every row it can.