How to Keep Leading Zeros in Excel ZIP Codes When Exporting
Question details
The user needs to retain leading zeros in ZIP codes when exporting data from Excel to external systems.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Exporting ZIP codes to external systems (such as the IRS) that strictly require exact 5-digit text values.
- Observed behavior
- Applying a custom format of '00000' shows the leading zero visually, but the formula bar and exported files drop it because the system still treats the ZIP code as a standard number.
Identify whether your ZIP codes are already typed into the sheet or if you are about to import them from a CSV file, as the best preservation method depends on your data source.
Use the TEXT Function to Convert Numbers to 5-Digit Text
This method uses a formula to permanently convert existing numeric ZIP codes into proper 5-digit text values with leading zeros.
Applying a custom format only changes how the data looks on the surface, but the TEXT function actually changes the underlying data into a text string. This ensures the zero is kept during export.
Right-click the column letter next to your ZIP codes and select 'Insert' to create a new blank column.
Click the first cell in your new column and type =TEXT(A1, "00000") (replace A1 with the cell containing your ZIP code).
Press Enter, then click the cell again and double-click the small square at the bottom right corner (the fill handle) to drag the formula down to the rest of the rows.
Select the new column, copy it, right-click the same selection, and choose 'Paste as Values'. This removes the formula and leaves only the text, which is now safe to export.

Import CSV Data as Text via Power Query
Best for importing raw CSV files to prevent the spreadsheet from dropping zeros automatically upon opening.
Prefix with an Apostrophe for Manual Entry
Ideal for quick, manual data entry of a small handful of ZIP codes.
Keep Leading Zeros Easily in WPS Office
WPS Spreadsheet provides a highly compatible and efficient environment for data handling. You can easily format cells as text, use functions like TEXT, or rely on its intuitive data import wizard to ensure leading zeros are never lost during CSV exports.
- 1. Open Your File: Launch WPS Spreadsheet and open the document containing your data.
- 2. Format Cells as Text: Select the target column, right-click and choose 'Format Cells', then set the category to 'Text' before pasting your ZIP codes.
- 3. Use the Formula Builder: Alternatively, type =TEXT(A1, "00000") to quickly bulk-convert existing numbers into proper text values.
- 4. Save as CSV: Go to Menu > Save As, select CSV format, and export your file knowing all leading zeros are fully intact.

Frequently Asked Questions
Why does Excel drop the leading zero in my ZIP codes?
By default, spreadsheet applications automatically categorize data made entirely of digits as numbers. Since leading zeros hold no mathematical value (e.g., 02865 is mathematically just 2865), they are automatically stripped out to save space.
Can I just use the Custom Format '00000' to fix the export?
No. Custom formatting only changes the visual display on your screen. The underlying value in the formula bar remains a standard number without the zero, meaning the zero will still be lost upon exporting to CSV or other text formats.
How do I recover leading zeros if I already saved the file?
If the zeros were dropped and the file was saved, the original zeros are lost. You will need to restore them by creating a new column and using the =TEXT(cell, "00000") formula, then copying and pasting the result as values.




