EthicalFusion
Data & Developers

How to Convert CSV to JSON (and JSON Back to CSV)

Paste CSV into a free converter and get a JSON array of objects keyed by the header row. How it treats headers, quotes and types, and how to go back to CSV.

By the EthicalFusion team Published Updated 7 min read

To convert CSV to JSON, paste the CSV into the free CSV to JSON converter and click Convert. You get a JSON array with one object per data row, using the first row as the property names. Every value comes out as a string, so 28 becomes "28" and a phone number keeps its leading 0. Copy the result into your code, an API request or a file.

This guide shows the exact output shape, how the converter handles awkward rows (quoted commas, missing cells, duplicate headers), how to turn strings into numbers in code, and how to go back from JSON to CSV. Everything runs in your browser, so pasted data isn't uploaded anywhere.

A worked example

Paste this CSV, which has a header row and two data rows. The second city contains a comma, so it is wrapped in double quotes:

name,age,city,pin
Asha,28,Pune,411001
Ravi,31,"Delhi, NCR",110001

The converter returns this (it prints each key on its own line with two-space indentation; it is shown compactly here):

[
{"name": "Asha", "age": "28", "city": "Pune", "pin": "411001"},
{"name": "Ravi", "age": "31", "city": "Delhi, NCR", "pin": "110001"}
]

Three things to notice. The output is an array of objects, the shape most APIs and JavaScript code expect. The keys come straight from the header row. And "Delhi, NCR" stayed in one value because it was quoted, which is the rule a naive "split on commas" script gets wrong.

How the converter reads your CSV

We ran the converter's own code on a set of tricky inputs. This is what it does:

SituationWhat happensExample
Numbers, true/false, blanksAll become strings28 → "28", true → "true", empty → ""
Comma inside quotesKept in the value"Delhi, NCR" → Delhi, NCR
Doubled quote inside quotesBecomes one quote mark"Ravi ""RK"" Kumar" → Ravi "RK" Kumar
Line break inside quotesKept as \n in the string"line1↵line2" → "line1\nline2"
Row with fewer values than headersMissing keys get ""A row of just 3 → other keys ""
Row with more values than headersExtra values are dropped silentlyA sixth value under five headers is lost
Spaces after commas in the headerKept in the keyname, age → key " age"
Two columns with the same headerThe later one overwrites the earliername,name / A,B → {"name": "B"}
Blank lines, Windows line endingsSkipped, handledNo empty objects
Semicolon or tab separatorsNot splitname;city → one key "name;city"
A stray quote inside an unquoted valueStarts a quoted field and swallows what follows5" pipe → rest of the file in one value
Only a header rowError"Need a header row and at least one data row."

Most of this follows RFC 4180, the usual description of CSV: commas separate fields, fields with commas, quotes or line breaks are quoted, and a quote inside a quoted field is doubled. The last three rows are where your input needs care. For inch marks write "5"" pipe", and make sure the header has no stray spaces or repeated names.

Why every value is a string

The converter doesn't guess types, and for most spreadsheet data that is the safe choice:

  • Leading zeros. JSON numbers can't have leading zeros (RFC 8259 says so in as many words), so 09876543210 or the employee code 007 can only be kept as strings.
  • Long IDs. JavaScript stores numbers as 64-bit floating point and is exact only up to 9,007,199,254,740,991. A 12-digit Aadhaar number fits, but a 19-digit card number or reference would silently change if it were parsed as a number.
  • Codes that look like numbers. PIN codes, roll numbers and 1E5-style part codes are labels, not quantities.

Convert the fields that really are numbers or booleans in your code. In JavaScript:

const rows = JSON.parse(text).map(r => ({ ...r, age: Number(r.age), active: r.active === "true" }));

In Python, csv.DictReader also gives you strings, and you convert with int(row["age"]). Leave IDs, phone numbers and PIN codes as strings.

Getting a clean CSV to start with

  • From Excel: use File › Save As › CSV UTF-8 (Comma delimited), so Hindi and ₹ survive. Check that leading zeros and long numbers are still right in the sheet first; the guide how to convert Excel to CSV covers the traps.
  • Copied cells: cells copied from Excel or Google Sheets are separated by tabs, not commas. Paste them into the TSV to JSON converter instead.
  • Semicolon files: CSVs from European software often use semicolons. Re-export with commas, or replace the separators carefully (not inside quoted text).
  • Header row: one row of short, unique names with no spaces around them, such as name,age,city. Delete any title rows above it.

Have an .xlsx file? The Excel to JSON converter reads it directly, but behaves differently. It keeps numbers as JSON numbers, gives dates as Excel serial numbers (15 August 2026 arrives as 46249) and leaves empty cells out of each object. See how to convert Excel to JSON for those details.

JSON back to CSV

The JSON to CSV converter does the reverse. Paste a JSON array of objects and it builds the header from every key it finds, in the order they first appear, so no field is dropped even when objects differ. For this input:

[{"id": 1, "name": "Asha", "city": "Pune, MH"},
{"id": 2, "name": "Ravi", "email": "r@x.in", "addr": {"pin": "110001"}, "ok": true, "note": null}]

it returns:

id,name,city,email,addr,ok,note
1,Asha,"Pune, MH",,,,
2,Ravi,,r@x.in,"{""pin"":""110001""}",true,

  • Missing keys and null become empty cells.
  • Values with commas, quotes or line breaks are quoted.
  • Nested objects and arrays aren't flattened into columns. Each is written as JSON text in a single cell, which is why addr holds {"pin":"110001"}.
  • The top level must be an array. An API reply such as {"data": [ … ]} gives the error "Expected a JSON array of objects", so copy just the array. An array of plain values like [1, 2] produces blank lines rather than a column.

The result is text to copy. To open it in Excel with Hindi intact, paste it into Notepad and save it as a .csv with UTF-8 with BOM encoding. Or skip CSV and upload the JSON to the JSON to Excel converter, which keeps string values as text and leaves nested objects out.

What developers use it for

  • Seed data and test fixtures for an app, built from a sheet a colleague maintains.
  • Mock API responses while the real back end isn't ready.
  • Front-end tables, charts and dropdowns, such as a list of states and districts kept in a spreadsheet.
  • Imports into document databases or APIs that accept JSON but not CSV.

After converting, check the output with the JSON validator. The guides how to format JSON and the most common JSON errors and how to fix them help when you edit it by hand. For a database rather than JSON, the CSV to SQL converter writes INSERT statements; for typed code, JSON to TypeScript builds an interface from the result.

Frequently asked questions

Does the converter turn numbers into JSON numbers?

No. Every value is a string, including numbers, true/false and empty cells. That protects IDs and phone numbers; convert real numeric fields in your code with Number() or int().

Can I convert a CSV that has no header row?

Not directly: the first line always becomes the property names. Add a header line such as name,age,city at the top before pasting.

Can it create nested JSON?

No. CSV is flat, so the output is an array of flat objects. A header such as address.city stays a single key with a dot in it; build nested objects in code if you need them.

How big a CSV can I paste?

There is no fixed limit, because the conversion happens in your browser, but a very large paste can make the page slow on a phone. For files of many megabytes, a short script is more practical.

Is my data sent to a server?

No. The converter's code runs in your browser tab, so customer lists and other private data never leave your device.

Sources: IETF RFC 4180 (CSV, October 2005); IETF RFC 8259, The JavaScript Object Notation (JSON) Data Interchange Format (STD 90, December 2017). Converter behaviour checked by running the site's code, October 2026.

  • #csv to json
  • #json to csv
  • #convert csv to json array
  • #csv parser
  • #json

Tools used in this guide

Free, no sign-up, and they run in your browser.

About EthicalFusion

EthicalFusion offers 321 free online tools for money, documents, images, writing and code. This guide was written by the team that builds them. Calculators give estimates, so confirm important figures with your bank, CA or doctor.

About us Suggest a correction

Keep reading

All articles