File conversion

How to convert CSV to JSON with IDs kept as strings

Convert CSV to a JSON array of objects in your browser. Codes with leading zeros and long IDs stay strings, amounts become numbers. Rules and examples.

DealMahal team · Published 6 December 2026 · 5 min read

To convert a CSV file to JSON, open our free CSV to JSON converter, drop in the file or paste the data, and click Download JSON. You get an array with one object per row, keyed by the header row. Amounts become JSON numbers, while ZIP codes, product codes with leading zeros and long IDs stay strings, so nothing your app relies on is changed. The conversion runs in your browser; the file is not uploaded.

A worked example

Input CSV:

order_id,zip,amount,discount,paid,created,note
1234567890123456789,02134,"1,250",0.75,TRUE,2026-12-05,

Output JSON (with "Save numbers as numbers" ticked):

[
  {
    "order_id": "1234567890123456789",
    "zip": "02134",
    "amount": 1250,
    "discount": 0.75,
    "paid": "TRUE",
    "created": "2026-12-05",
    "note": ""
  }
]

What happened to each value:

ColumnBecameWhy
order_idstring16 or more characters always stay strings, so no digits are lost in any tool that reads the JSON
zipstring "02134"starts with 0 followed by a digit, so it is a code, not a number
amountnumber 1250a plain number; thousands commas are understood
discountnumber 0.75a zero before the decimal point is a normal number
paidstring "TRUE"text that looks like a boolean is left as text
createdstringdates are kept exactly as written
noteempty string ""empty cells become empty strings

Untick "Save numbers as numbers (Excel and JSON). Leading zeros are always kept." and every value becomes a string. Choose that when the receiving system does its own type conversion.

Step by step

  1. Open CSV to JSON.
  2. Choose or drop a CSV, TSV or TXT file up to 50 MB, or paste rows into the box.
  3. Check the preview of the first 100 rows. The column names there become your JSON keys.
  4. Decide on the number option (above).
  5. Click Download JSON. The file is indented with two spaces, so it is readable in any editor.

How the keys are made

The first non-empty line is the header row, and each header becomes a key, with a few clean-ups so every key is usable:

  • spaces at the ends are removed and runs of spaces inside are reduced to one;
  • an empty header becomes column_1, column_2 and so on, by position;
  • a repeated header gets a number: two amount columns become amount and amount_2;
  • completely empty rows are skipped.

Keys keep their original case and inner spaces. If your app expects snake_case keys, rename the headers in the CSV before you convert.

Separators and encodings

The converter checks your file with comma, tab, semicolon and pipe, and uses the one that splits the rows most consistently, so semicolon files from European versions of Excel work without changes. A .tsv file is always read as tab separated.

Encoding is detected too: UTF-16 by its marker, otherwise UTF-8, with a fallback to Windows-1252 for older exports. If accented names look wrong in the preview, see fixing CSV encoding.

Why IDs must stay strings

JavaScript and many JSON parsers store numbers as 64-bit floating point, which holds integers exactly only up to 9,007,199,254,740,991 (16 digits). An 18 or 19 digit order ID stored as a JSON number will be silently rounded by those parsers. Keeping it as a string avoids that, and it is the same reason long IDs break in spreadsheets: see why Excel turns long numbers into scientific notation.

Codes with leading zeros are the other trap. 02134 as a number is 2134, which is no longer a valid ZIP code.

Limits and edge cases

SituationWhat happens
File over 50 MBNot accepted; split it first
More than 2,000 columnsStops with a message naming the column count
Dotted headers such as address.cityKept as flat keys; no nesting is rebuilt
An empty fileAn error message, no download
Values like $99 or 15%Strings, exactly as written
Negative numbers such as -42Numbers

Using the file in code

The output is standard JSON, so any language reads it directly:

import json
rows = json.load(open("orders.json", encoding="utf-8"))
total = sum(r["amount"] for r in rows if isinstance(r["amount"], (int, float)))
const rows = await (await fetch("orders.json")).json();
const ids = rows.map(r => r.order_id); // strings, every digit intact

Two habits keep the data safe once it is loaded:

  • Treat ID and code fields as strings in your own code too. Converting them with int() or Number() brings back the problems described above.
  • Check for empty strings. An empty cell arrives as "", not null and not 0, so a sum over a column with blanks needs the type check shown in the Python example.

When JSON is the better choice

You are sending the data toBetter format
A web app, an API or a scriptJSON: types are explicit and nothing reinterprets your codes
Someone who will open it in ExcelAn Excel file, not CSV or JSON
A database bulk importUsually CSV, which most import tools expect
A config file or test fixtureJSON

JSON is larger than the same data in CSV because every row repeats the keys. For very large tables that will only ever be read by a database, CSV stays the leaner choice.

Going the other way, and from Excel

More free file tools are on the tools page.

Frequently asked questions

What does the JSON look like?

An array with one object per row. Each object uses the header row as its keys, in the same order as the columns.

Will numbers be numbers in the JSON?

Yes, if Save numbers as numbers is ticked (the default). Codes that start with 0 and values of 16 or more characters stay strings, so IDs and ZIP codes are not damaged. Untick it to make every value a string.

What happens to empty cells?

They become empty strings, not null. If your app needs null, replace empty strings after loading the file.

Can it rebuild nested JSON from dotted column names?

No. A column called address.city stays a key with a dot in it. The output is always flat: one level of keys per object.

Spotted an error? Write to dealmahal.official@gmail.com.

Questions or corrections: dealmahal.official@gmail.com.

Keep reading

All posts