CSV to JSON without losing leading zeros or large IDs
An account ID is not a number to do maths with. Keep it intact when changing formats.
If 001 is an account ID, turning it into 1 is a broken conversion. The same goes for a long post ID that changes its last digit.
CSV does not tell a converter which columns are identifiers. The safest starting point is to keep cells as strings and convert only the values you actually need as numbers or booleans.
Start with a file that exposes the problem
Our sample has leading zeros, two 19-digit IDs, a comma inside a quoted field, and the name Zoë. None of the rows contain real account data.
account_id,post_id,name,note,active
001,1234567890123456789,Alex,"Design, then share",true
002,9876543210987654321,Zoë,"Keep leading zeros",false
{
"account_id": "001",
"post_id": "1234567890123456789",
"name": "Alex",
"note": "Design, then share",
"active": "true"
}With CozyToolkit's default settings, 001 stays "001", the long IDs stay quoted, and "Design, then share" stays one value. Even true remains the string "true". That last detail is intentional: the converter has not been asked to guess types.
Convert it without changing the identifiers
- Download the sample CSV above, or use Try this CSV to open it in the data converter.
- Choose CSV as the source and JSON as the destination. Auto-detect also recognises this sample.
- Keep First row contains headers on and Detect numbers and booleans in CSV off in Options.
- Check the JSON output. The values for
account_idandpost_idshould have quotes around them. - Download the JSON and check it in the application that will use it. A correct export can still be changed by the next importer.
The table preview is useful for checking columns and rows. Use the JSON view when checking types: a quoted string and a number can look identical in a table.
When type detection helps—and when it does not
If a CSV contains quantities such as 12 and flags such as true, Detect numbers and booleans in CSV can turn them into JSON numbers and booleans. In our converter, a value like 001 stays a string even with detection enabled.
A long integer is different. With detection on, our converter preserves its digits in the exported JSON using a lossless-number parser. But it is now an unquoted number. The program reading that file must also handle it precisely.
JavaScript's largest safe integer is 9,007,199,254,740,991. Ordinary JSON.parse converts JSON numbers into JavaScript numbers, and values beyond that safe range can be rounded. MDN explains the safe-integer limit.
For example, in JavaScript:
JSON.parse('{"id":1234567890123456789}').id
// 1234567890123456800
JSON.parse('{"id":"1234567890123456789"}').id
// "1234567890123456789"
If you will never add, subtract or average an ID, keeping it as a string avoids this problem. The current converter's type-detection switch applies to the whole file, not individual columns. For mixed IDs and quantities, leave it off, then explicitly convert the quantity fields in the system that consumes the data.
If the CSV is already damaged
A converter cannot recover digits that an earlier spreadsheet export has rounded away. Nor can it infer whether 1 was originally 001 or 0001.
Open the original CSV as text before converting. If the digits are already missing, go back to the source export. Adding zeros or inventing the last digits afterward is not a repair.
What we checked
On 28 September 2026, we ran the downloadable file through CozyToolkit's conversion function with type detection off and on. We checked both long IDs, the leading zeros, the quoted comma and Unicode in the output. The measurements file includes both outputs for comparison. Files are processed in your browser; this test did not use an AI model.