How to Convert CSV to JSON

CSV stores data in rows and columns. JSON can represent each row as an object, with column headings as keys.

Map your CSV headers to JSON keys

To convert CSV to JSON, identify the delimiter, use the first row as column names and turn each subsequent row into an object. The array contains one object per data row. Make a copy of the input before changing it.

Example CSV:

id,name,city
001,Lina,Cairo
002,Sam,"Paris, France"

Expected JSON from our converter:

[
  {"id":"001","name":"Lina","city":"Cairo"},
  {"id":"002","name":"Sam","city":"Paris, France"}
]

Notice that the quoted city remains one field and the identifier keeps its leading zeros. Values are strings, not inferred numeric or Boolean types.

Use the free CSV ↔ JSON converter

  1. Choose CSV to JSON as the direction and comma as the delimiter for the example.
  2. Paste the CSV text into the input pane and choose Convert.
  3. Inspect the output array and row and column counts. The Sample control provides another example.
  4. Copy the result when your browser permits it. Keep the original file for comparison.

Use semicolon or tab if that is the actual separator in your source. For example, a row written as name;city needs semicolon mode. The widget does not automatically infer a delimiter or load a spreadsheet workbook.

Try CSV ↔ JSON

If the preview does not load, open CSV ↔ JSON and customize it.

Handle commas and quotes inside fields

A quoted CSV field can contain its separator or a line break. To represent a double quote inside a quoted field, double it. For example, "She said ""hello""" represents a single field containing the quotation marks around hello. See RFC 4180 for common CSV conventions.

The current parser normalizes line breaks and reports malformed or unclosed quotes. If an entire row appears as one key, recheck the delimiter. Avoid simply replacing every comma with a different character, as that can change valid field content.

Validate headers and row widths

The converter treats the first row as headers. Empty headings are given names such as col_1; duplicates are renamed with suffixes. Blank or missing cells become empty strings, and cells beyond the header width are not represented in the resulting object. Before converting, fix headers and make each row the same width to avoid accidentally dropping values.

Inspect leading zeros, empty values, quoted text and expected row count. If your receiving program needs numeric or Boolean values, explicitly convert and validate them using its schema. A display of valid JSON does not establish that the data meets your application contract.

Convert JSON back to CSV

Change direction to JSON to CSV, choose the desired separator and paste an array of objects or arrays. Check the resulting headings and quoted fields instead of assuming a perfectly reversible type conversion. CSV cannot represent every nested JSON structure without a separate encoding convention.

The conversion runs client-side, but hosted assets and analytics may make network requests. Use fabricated examples online; keep private or large production datasets in a trusted local workflow. For a line-by-line comparison of two text exports, see our text comparison guide.

Common questions

Why are my numbers in quotes?

CSV has no inherent JSON types. This converter keeps CSV values as strings, including numeric-looking identifiers.

What if there are no headers?

Add a header row before conversion. The first existing row is treated as the header.

Will converting back preserve every property type?

Not necessarily; CSV is flat text. Validate the resulting schema and keep the original input.