CruxDevCruxDev Tools Prompts
dev Utility • Zero-Server Privacy • 100% Client-Side

CSV to JSON Converter

Convert CSV to clean JSON with an RFC 4180 parser — quoted fields, embedded commas, and type casting handled.

Overview

Paste comma-separated data and get clean JSON back as you type — an array of objects when the first row is headers, an array of arrays when it is not. The parser is a hand-written RFC 4180 state machine, so quoted fields, doubled quotes, and commas or newlines inside quotes survive the trip intact.

How It Works

Paste CSV into the input and the JSON output updates immediately. Two checkboxes control the shape: First row is headers turns rows into objects keyed by the trimmed header names, and Convert numeric cells to numbers casts cells like 12 or 3.14 into real JSON numbers instead of strings. Copy the pretty-printed result from the output panel when it looks right.

Step-by-Step Usage Guide

  1. Paste your CSV into the input area — the sample shows the expected shape.
  2. Leave First row is headers checked for array-of-objects output; uncheck it for array-of-arrays.
  3. Toggle Convert numeric cells to numbers depending on whether figures should arrive as JSON numbers or strings.
  4. Copy the JSON output from the output panel.

Technical Specifications & Standards

The parser walks the input character by character with an in-quotes flag rather than splitting on commas. A double quote toggles quoted mode, a doubled quote inside a quoted field becomes a literal quote character, and commas or line breaks inside quotes are kept as cell content. CRLF, bare LF, and bare CR all terminate rows, and blank rows are skipped instead of becoming empty objects. Numeric casting goes through JavaScript's Number() conversion, so 1e3 becomes 1000 — and a ZIP code like 007 becomes 7, which is exactly why the toggle exists.

Targeted Use Cases

  • Turning a spreadsheet export into JSON that a script, test fixture, or API mock can consume directly.
  • Previewing how a CSV file from a client will look once a backend parser turns it into records.
  • Generating seed data for a database or JSON-based CMS from a list maintained in a spreadsheet.
  • Flattening log excerpts or report dumps that use comma-separated columns into inspectable objects.

Notes & Gotchas

  • The delimiter is a hard comma. Excel exports configured for a European locale use semicolons — replace them with commas first or each line arrives as one cell.
  • Watch numeric casting on identifier-like columns: leading zeros (007), hexadecimal-looking strings, and scientific notation are all cast through Number(). Switch the toggle off and cast in your own pipeline when fidelity matters.
  • Empty cells become empty strings, never null, and the words true, false, and null stay strings — only numeric-looking cells are cast.
  • A field with an unclosed quote does not raise an error; the parser treats the rest of the input as that field. If the output looks short, check for an unbalanced quote near the end.

Frequently Asked Questions

Does it handle commas and newlines inside a field?

Yes. Anything between double quotes is treated as one cell, doubled quotes inside it become literal quote characters, and embedded line breaks stay inside the cell.

Why did my numbers arrive as strings?

The Convert numeric cells to numbers checkbox was off, or the cell was empty. With it on, any cell that survives Number() without becoming NaN is emitted as a JSON number.

Can I upload a .csv file instead of pasting?

No. The tool works on pasted text only — which is also why nothing leaves your browser, since there is no upload step at all.

Can it convert JSON back to CSV?

Not here. This tool is one-directional, CSV to JSON, by design.