TBToolbox
Developer Tools

CSV to JSON

CSV to JSON uses the first parsed row as exact property names and requires at least one data row. Every cell becomes a string; missing trailing cells become empty strings and extra cells beyond the header are discarded. Duplicate headers overwrite earlier properties. The custom parser handles common quoted commas, doubled quotes, and quoted line breaks, but does not reject every malformed quote pattern or infer numbers, booleans, dates, encoding, or schema.

Runs locally — files stay on your device
Quick answer

Are numeric CSV cells converted to JSON numbers?

No. Every output value is a string.

CSV has syntax but usually no intrinsic types

A header-based import maps column positions to names. Duplicate or empty headers and uneven row widths require policies that this page does not validate.

How it works

A character-level parser reads comma-separated rows; the first row supplies keys and each later row is converted with Object.fromEntries.

Key concepts

All strings

The text 001 stays "001", while 12 stays "12".

Header collisions

Later duplicate names replace earlier cells in each object.

When to use it

  • Convert a small conventional CSV table.
  • Inspect rows as JSON objects.
  • Prepare string-valued fixture data.

When not to use it

  • Do not expect delimiter detection.
  • Do not use duplicate headers.
  • Do not import hostile spreadsheet formulas into another spreadsheet without sanitization.

Worked examples

Simple table

Input
id,name\n1,Ana
Expected output
[{"id":"1","name":"Ana"}]

Values remain strings.

Quoted comma

Input
name,note\nAna,"a,b"
Expected output
note equals a,b

Quotes protect the comma.

Short row

Input
a,b\n1
Expected output
b is empty string

Missing cells are filled.

Common mistakes

Expecting type inference

No conversion occurs. Correction: Apply a reviewed schema after import.

Duplicate headers

Data is overwritten. Correction: Make header names unique.

Assuming strict validation

Unclosed quotes may not produce a clear error. Correction: Use a standards-focused parser for production.

Best practices

  • Use a unique nonempty header row.
  • Validate row widths and types afterward.
  • Treat imported formulas and text as untrusted.

Related operations and differences

JSON to CSV

Choose JSON to CSV when you need to convert an array of JSON objects to CSV.; use CSV to JSON specifically for csv to json.

CSV to TSV

Choose CSV to TSV when you need to convert comma-separated data to tab-separated data.; use CSV to JSON specifically for csv to json.

JSON to XML

Choose JSON to XML when you need to convert JSON objects into formatted XML.; use CSV to JSON specifically for csv to json.

JSON to YAML

Choose JSON to YAML when you need to convert JSON data into readable YAML.; use CSV to JSON specifically for csv to json.

TSV to CSV

Choose TSV to CSV when you need to convert tab-separated data to CSV.; use CSV to JSON specifically for csv to json.

XML to JSON

Choose XML to JSON when you need to convert XML elements and attributes into JSON.; use CSV to JSON specifically for csv to json.

Limitations and privacy

  • Comma delimiter only in this UI path.
  • No strict malformed-CSV diagnostics, type inference, duplicate-header warning, extra-cell retention, schema, encoding/BOM controls, formula defense, or streaming.

The pasted data is parsed and transformed locally in this browser.

Frequently asked questions

Is a header required?

Yes, plus at least one data row.

Are numbers parsed?

No.

What happens to extra cells?

Cells beyond the header width are omitted.

Are duplicate headers rejected?

No.

References