CSV Fixes· 8 min read

How to Keep Leading Zeros in CSV Files When Opening in Excel

Excel often removes leading zeros from CSV files because it guesses that values like 00123 are numbers. That is a problem for ZIP codes, product IDs, employee IDs, bank references, and SKUs.

Why Excel Removes Leading Zeros

CSV files do not store cell formatting. They are plain text. When Excel opens a CSV directly, it tries to detect each column type automatically. If a column looks numeric, Excel converts it to a number, and numbers do not preserve leading zeros.

That means 00045 becomes 45. The value may look small, but the damage is large if the field is an identifier rather than a calculation number.

Best Method: Import Instead of Double-Clicking

  1. Open Excel first.
  2. Go to Data > From Text/CSV.
  3. Select the CSV file.
  4. Choose Transform Data or set column data types before loading.
  5. Set ID, ZIP, SKU, or code columns to Text.
  6. Load the data into the workbook.

This tells Excel not to guess. Once the column is explicitly text, leading zeros are preserved.

Alternative: Convert CSV to Excel First

If you receive CSV files often, converting them to XLSX before editing can reduce accidental type changes. Use the CSV to Excel Converter to preview a file and create an Excel workbook. For sensitive files, the conversion runs in your browser.

How to Check Whether Zeros Were Lost

Compare the length of values before and after import. For example, if product codes must always be 8 characters, add a helper formula:

=LEN(A2)

Any value shorter than expected should be investigated. Do this before sending the file to customers, importing it into a database, or using it in a lookup.

Prevention Checklist

  • Do not double-click important CSV files with ID columns.
  • Import the CSV and set code columns to Text.
  • Keep a copy of the original CSV.
  • Validate expected text lengths after import.
  • Use XLSX for editing when identifiers must preserve exact formatting.

Convert CSV to Excel safely

Preview CSV data and download an XLSX workbook from your browser.

Open CSV to Excel Converter →