How to Add Leading Zeros Back to ZIP Codes in a CSV That Excel Stripped
To add leading zeros back, pad every all-digit code that is too short to its true length, so 2134 becomes 02134. The restore leading zeros in CSV tool does it in your browser. Upload a CSV or .xlsx file, tick the code columns (headers such as Zip or Postal code are ticked for you), set the length in digits, check the examples and download.
The file is read on your device and not uploaded. This guide is about repairing a file that has already lost its zeros. To avoid losing them when you open a CSV, read opening a CSV in Excel without losing leading zeros.
Why the zeros disappear
Excel and other spreadsheets treat a cell of digits as a number, and a number has no leading zeros. A ZIP code such as 02134 is saved as 2134 the moment the file is opened and saved again. The same happens to phone prefixes, account numbers, product codes and some IDs.
No tool can know which codes were really short, so set the length to the true one for that column.
Doing it by hand
In Excel or Google Sheets, with the codes in column A:
- Formula.
=TEXT(A2,"00000")returns a five-character text value with zeros restored. - Another way.
=RIGHT("00000"&A2,5)does the same, and works on cells that are already text. - Keep the result. Copy the new column and paste as values, then delete the original.
A custom number format of 00000 only changes how the cell looks, and the value underneath is still the number 2134. If a file is read by another program, check what was actually written by opening it in a plain text editor.
Step 1: load the file
Upload the CSV or .xlsx, or paste the cells with the header row first.
Step 2: tick the columns and set the length
Tick the columns that hold codes and set how many digits they should have, 5 for a US ZIP code. Different columns can need different lengths. Run the tool once for each length, ticking the matching columns each time.
Step 3: check the examples and download
Examples show what changed, with counts of the cells padded and of those left alone.
Which cells are changed
Only cells in the ticked columns that are made entirely of digits and are shorter than the length you set. Longer codes, blanks, and cells with letters, spaces inside, dashes or a decimal point are left alone and counted, so a ZIP+4 code such as 02134-1234 is not touched.
Stopping it happening again
Open saved CSVs in Excel through Data, From Text/CSV, and set the code column to Text before loading. Double-clicking the file drops the zeros once more. To convert the file to a workbook with the columns stored as text, use CSV to Excel. For phone numbers, see cleaning phone numbers in a CSV and the phone number formatter.
What this tool cannot do
- It cannot tell which codes were short on purpose.
- Only cells made of digits are padded.
- Excel may drop the zeros again when it opens the saved file.
- Only the first sheet of a workbook is read.
Check the addresses on the same list
Codes restored, addresses still unchecked. Upload the list on the verify page: the first 100 email checks are free with a Google sign-in, no card. Each address comes back valid, risky or invalid with a reason, and nothing is sent to anyone on the list. For larger lists, see bulk email verification and pricing.
Restore your zeros now
Open the restore leading zeros in CSV tool.
Common questions
How do I add leading zeros back to ZIP codes in a CSV?
In a sheet, =TEXT(A2,"00000") pads to five digits. A leading zero restorer does it for the columns you tick and leaves everything else as it was.
How many digits is a ZIP code?
Five in the United States. Many other countries use four, six or more, so set the length for your data.
What about ZIP+4 codes with a dash?
They are left alone, because the cell holds more than digits.
Will it change codes that are already long enough?
No. Codes at or above the length are left alone and counted.
Why do the zeros vanish again in Excel?
Excel reads the file as numbers. Import it with Data, From Text/CSV and set the column to Text.
Check your list before you send
Real mailbox checks over SMTP, and nothing is sent to the address. Sign in with Google and your first 100 email checks are free, no card. Plans for bigger lists are on the pricing page.