Keep leading zeros and long IDs when converting CSV to JSON
A ZIP code like 02108 needs its first zero. Keep ZIP codes, product IDs, and other identifiers as text in the spreadsheet and in the JSON you export.
Import ID columns as text in Excel
When Excel reads an ID as a number, it drops leading zeros and keeps at most 15 significant digits. Open the original file through Data, then From Text/CSV. In the query editor, change the ID column to Text and replace the automatic type change before loading the data.
Export a UTF-8 CSV and check a few IDs in a plain-text editor. If Excel already stripped zeros or rounded an ID, start again from the original file. See Microsoft’s Excel import instructions for the menu steps.
See what happens to the same IDs in JSON
Paste this sample into the CSV column converter, leave the header option on, and select value. The default JSON setting keeps each value as a string.
value
001
9007199254740993
1.2300
42
["001", "9007199254740993", "1.2300", "42"]
["001", "9007199254740993", 1.23, 42]
Type detection keeps 001 as a string because it starts with zeros. It keeps 9007199254740993 as a string because the number is outside JavaScript’s safe integer range. It converts 42 to a number and writes 1.2300 as 1.23. Leave values as strings when an ID or decimal needs to keep its original digits.