Excel removes leading zeros from your CSV — how to keep them
Published:
You open a CSV in Excel and employee ID 007 has become 7, the ZIP code 02134 is now 2134, and order number 12345678901234567890 shows as 1.23457E+19. Excel is trying to be helpful: anything that looks like a number is converted into one.
Why the zeros disappear
When Excel opens a CSV, it inspects each value and converts anything numeric-looking into a number. Mathematically, 007 and 7 are the same, so the leading zeros are discarded.
But in real data, many of these values aren’t quantities at all — they are labels that happen to contain digits:
- ZIP and postal codes, employee and student IDs, product codes
- Phone numbers with a leading 0
- Account, card and order numbers
Long numbers are even more at risk
Excel stores numbers with 15 significant digits of precision. Convert a 16- or 20-digit ID into a number and every digit after the 15th becomes 0; Excel then displays it in scientific notation, like 1.23457E+19. If you save the file in that state, the original number is gone for good. Credit-card-length numbers and long order IDs are frequent victims.
Fix 1: Import the columns as text in Excel
- In Excel, choose Data → From Text/CSV and pick the file.
- Click Transform Data to open the Power Query editor.
- For each column that must keep its zeros, click the type icon in the column header and choose Text, then Replace current.
- Click Close & Load.
This is precise, but tedious with many columns and needs repeating for every file.
Fix 2: Convert CSV to XLSX without changing values
The CSV to XLSX converter types values conservatively, so nothing is silently altered:
- Only unambiguous numbers such as
42or3.14become numbers. - Values with leading zeros, like
007, stay text. - Numbers longer than 15 digits stay text, exactly as written.
- Formatted values such as
1,234are kept as they appear.
To keep absolutely everything as text, choose Keep everything as text under Options → Values. The resulting XLSX opens in Excel with every zero in place. The CSV to JSON converter applies the same rules, keeping codes and long IDs as strings.
Fix 3: Exporting from Excel without losing zeros
Cells formatted as Text in Excel (often marked with a small green triangle) are exported exactly as written by the XLSX to CSV converter. Cells that only display zeros through a number format like 000 are exported the way they appear on screen.
Habits that prevent the problem
- Treat codes and IDs as text from the start — you never calculate with them.
- Don’t save a CSV straight after opening it in Excel; you may overwrite it with the damaged values.
- For important data, exchange XLSX files rather than CSV.
Summary
Missing leading zeros come from Excel mistaking codes for numbers. Import the columns as text, or convert the CSV with a tool that types values conservatively. For more on choosing between the two formats, see CSV vs XLSX.