To open a CSV in Excel without losing leading zeros, do not double-click the file. Import it through Data > From Text/CSV, choose Transform Data, and set every ID column, such as ZIP code, EIN and account number, to Text before loading. Excel then keeps 01234 as 01234 instead of converting it to the number 1234.
Why Excel strips leading zeros from a CSV
Excel strips leading zeros from a CSV because it guesses that a column of digits is a number, and numbers have no leading zeros. A CSV file stores only text with commas between fields. It carries no instruction saying "this column is an identifier," so Excel converts 01234 to 1234 as it opens the file.
The CSV format itself explains the gap. RFC 4180, the CSV format specification, defines records on separate lines and fields separated by commas, with optional double quotes around a field. It says nothing about data types. A ZIP code and a dollar amount look exactly alike in the file: a run of digits.
Excel fills that gap with its own rules. The Microsoft support article on keeping leading zeros and large numbers says Excel automatically removes leading zeros so that formulas and math work on the values. The Microsoft article on importing and exporting text files adds that when Excel opens a .csv file, it uses the current default data format settings to interpret each column.
A second loss affects long numbers. The same leading-zeros article says Excel has a maximum precision of 15 significant digits, so any digits after the fifteenth in a longer number are set to zero. A 16-digit account number opened as a number is changed, not just reformatted.
Newer versions give some control. The Microsoft article on automatic data conversions lists an option for "Removing leading zeros from numerical text and converting to a number," found under File > Options > Data on Windows. Turning it off changes how Excel treats CSV files you open. The article notes these options do not apply to data imported through Power Query, which has its own type settings.
Which tax CSV columns carry leading zeros?
Tax CSV columns that carry leading zeros are the identifier columns: ZIP codes, EINs and other TINs, state employer ID numbers, account numbers and control numbers. None of them are amounts, and none should ever be added up. Any of them can start with zero, and a column with even one such value is at risk.
| Column | Example value (fictional) | What Excel shows if converted | Why it matters |
|---|---|---|---|
| ZIP code | 02134 | 2134 | Mailing address no longer valid |
| Payer EIN, no hyphen | 041234567 | 41234567 | Eight digits fail a nine-digit check |
| Recipient TIN, masked | XXX-XX-0123 | XXX-XX-0123 | Not a plain run of digits, so less exposed |
| State employer ID | 0012345 | 12345 | No longer matches the state's records |
| Account number, short | 00451234 | 451234 | Cannot match the bank's statement |
| Account number, 16 digits | 4512349876123456 | 4512349876123450 | Digit past the fifteenth set to 0 |
| Control number | 00042 | 42 | Cannot match the form's Box d |
The TIN rows deserve a closer look. The IRS Instructions for Forms 1099-MISC and 1099-NEC say SSNs, ITINs and ATINs use the XXX-XX-XXXX format and EINs the XX-XXXXXXX format. An export that drops the hyphens leaves nine bare digits, which is the numerical text that Excel's leading-zero conversion acts on. Check whether your CSV keeps the hyphens before assuming a TIN column is safe.
State ID numbers vary in length and format. The IRS General Instructions for Forms W-2 and W-3 say state employer ID numbers are assigned by the individual states, so there is no single pattern to rebuild them from.
Pattern checks on TINs and EINs, such as confirming that an EIN has nine digits, catch many of these losses after the fact. The accuracy and security category covers those format checks.
Importing the CSV with text columns in Excel
Importing the CSV with text columns in Excel means using the Data tab's From Text/CSV import instead of opening the file, then changing each ID column's data type to Text in the Power Query editor before loading. Values come in exactly as written in the file, with every leading zero kept.
The steps, based on the Microsoft article on keeping leading zeros:
- Open a blank workbook. Do not double-click the CSV.
- On the Data tab, select From Text/CSV next to Get Data.
- Pick the CSV file and select Import.
- In the preview, select Transform Data (labeled Edit in some versions) to open the Power Query editor.
- Click the header of the first ID column, for example
payer_zip. - Go to Home > Transform > Data Type and select Text.
- When asked, select Replace Current, so Excel discards its own guess instead of adding a step after it.
- Repeat steps 5 to 7 for every ID column:
payer_ein,account_number,state_id. - Select Close & Load.
The Microsoft article notes that refreshing the data later reapplies those transformations, so the columns stay text if the CSV is updated and reloaded.
Leave amount columns as numbers. Box values such as wages or withholding need to be numeric for totals to work, and their display format is a separate choice covered in the post on Currency or Accounting format for tax amounts.
Saving is the last trap. The import-and-export article warns that saving a workbook as CSV keeps only the current worksheet and that some features may be lost. The zeros are written to the file if the cells hold text, but the next person who double-clicks that CSV will lose them again. Save the working copy as an Excel workbook, and export CSV only as a final step for a system that reads it.
Getting an Excel file instead of a CSV avoids the CSV import step. Schema Tax exports Excel as well as CSV and JSON, and masks SSNs and TINs to the last four digits before storage; the supported forms list shows which documents it reads. If you work in Google Sheets instead, the guide to tax data in Google Sheets covers bringing the same files in there.
Can leading zeros be restored after Excel drops them?
Leading zeros can be restored after Excel drops them only when every value in the column has a known fixed length, such as five-digit ZIP codes or nine-digit EINs. A formula can pad those back. Variable-length values, such as some account numbers and state IDs, cannot be rebuilt, and digits past the fifteenth are gone for good.
For fixed-length columns, the Microsoft article on keeping leading zeros suggests the TEXT function in an empty column. Its example =TEXT(A1,"00000") displays 00123 for a postal code stored as 123. For a nine-digit EIN, the pattern becomes =TEXT(A1,"000000000"). Copy the results and paste them back as values to replace the damaged column.
A custom number format such as 00000 looks like a fix but works differently. The same article says custom formats will not restore leading zeros that were removed before formatting. The cell can display a padded value while what it holds is a different number, which matters when the column is exported or matched against another list.
Variable-length IDs are the real loss. If a state ID could be six or seven digits, there is no way to know whether 12345 was 012345 or 0012345. The same holds for account numbers. The 15-digit limit is worse still: a 16-digit number has already had its last digit replaced with zero, and no formula can recover it.
The reliable fix is to go back to the source. Re-import the original CSV with the steps above, or re-export it from the tool that produced it. Keep the original file untouched for exactly this reason.