JSON ↔ CSV Converter
Convert between JSON and CSV formats with ease.
JSON → CSV

Utilities

JSON ↔ CSV Converter

Convert between JSON and CSV formats with ease.

JSON ↔ CSV Converter translates between the two most common tabular interchange formats with an explicit Convert click — no surprise rewrites while you type. The direction pill shows "JSON → CSV" (default) or "CSV → JSON"; Swap Direction flips it and pipes the current output back in for round-trip testing. JSON input accepts an array of objects or a single object (auto-wrapped), and CSV input is parsed with Papa Parse using header:true and skipEmptyLines.

Output is pretty-printed JSON with 2-space indent or clean CSV ready to download as converted.json / converted.csv. Share encodes input and mode into a URL hash so a teammate can reopen your exact state. Errors surface verbatim in a destructive Alert ("Please enter data to convert", "Empty input", or the parser's message). Everything runs locally through Papa Parse — nothing is uploaded.

How it works

jsonToCsv in lib/jsonCsv.ts does JSON.parse, wraps non-array values as [obj], then Papa.unparse(data, { delimiter: ',', header: true }). csvToJson runs Papa.parse(csv, { header: true, skipEmptyLines: true }) and rethrows the first Papa error message. Unlike csv-json-converter (which converts live via useEffect), this page only converts inside handleConvert on the "Convert" button click.

JSON output is always pretty-printed with JSON.stringify(result, null, 2). State (input, output, mode, error) lives in jsonCsvSlice; swapMode() flips direction. Share uses copyShareableUrl('json-csv', { input, mode }) with hash restore on mount (mode restored via a swapMode dispatch). No network — Papa Parse runs in the browser.

How to use

  1. Step "Input" — confirm the direction pill ("JSON → CSV" default) or click "Swap Direction".
  2. Paste data into "JSON Input" / "CSV Input" — the placeholder shows a mode-specific example.
  3. Click "Convert" — success toast ("JSON converted to CSV!" / "CSV converted to JSON!"); errors land in the destructive Alert.
  4. Read "CSV Output" / "JSON Output" (JSON is pretty-printed with 2-space indent).
  5. Copy via the icon or Download → converted.csv / converted.json.
  6. "Share" copies a state URL (toast "Link copied!"); reload restores input/mode.
  7. "Clear" resets input/output/error (toast "Cleared!").

Tips

  • Unlike csv-json-converter (auto-convert), this tool requires an explicit "Convert" click — paste freely without mid-edit errors.
  • CSV→JSON always pretty-prints with JSON.stringify(result, null, 2), so output is diff-friendly.
  • Papa errors are surfaced verbatim (the first error's message) — useful for diagnosing delimiter/header mismatches.
  • A single JSON object is accepted for JSON→CSV: it's wrapped into an array before Papa.unparse.

JSON ↔ CSV Converter FAQ

Does it convert automatically?

No — conversion happens only on the "Convert" button (handleConvert), not on every keystroke.

Which library converts?

Papa Parse — Papa.unparse for JSON→CSV and Papa.parse for CSV→JSON, both in lib/jsonCsv.ts.

What JSON shapes are accepted?

An array of objects, or a single object (which is wrapped into [obj] before unparsing).

Why "Empty input"?

jsonToCsv/csvToJson throw on blank input; the page also pre-checks with "Please enter data to convert".

Is my data uploaded?

No — conversion is local Papa Parse in the browser; Share only encodes state into the URL hash.

Credits

  • Papa Parse — JSON↔CSV conversion via Papa in lib/jsonCsv.ts
ShareTweet
More Utilities

Command Palette

Search for a command to run...