How to stop Excel removing leading zeros from a CSV file
30 November 2026
To keep leading zeros and long numbers, don't double-click the CSV file. Import it with Data > From Text/CSV, choose Transform Data, and set the code columns to Text before the data reaches the sheet. In Excel for Microsoft 365 and Excel 2024 you can also switch off some of the changes under File > Options > Data > Automatic Data Conversion, but those settings don't cover everything.
What Excel does to a CSV when you open it
A CSV file is plain text, so Excel guesses what each column holds. We opened a test file in Excel for Microsoft 365 on a PC set up for the UK:
- Leading zeros went. The code 007 became 7, and the phone number 07700900123 became 7700900123.
- Long numbers went into scientific notation. The 13-digit barcode 5012345678900 showed as 5.01235E+12, and +447700900123 as 4.47701E+11.
- Digits after the 15th were lost. Excel keeps 15 significant digits, and Microsoft says any digits past the 15th become zero. A 19-digit order number can't be got back.
- An E became an exponent. The reference 1E5 became 1.00E+05.
It gets worse if you then save the file as a CSV. Excel writes what the cells show, so our barcode was saved as 5.01235E+12 and 007 as 7, and the lost digits were gone from the file for good. Keep the original, and save your work as .xlsx.
1. Data > From Text/CSV, with Text columns
Good for: Excel for Windows 2016 or later, including Microsoft 365, and files you'll import again.
- In a blank workbook, choose Data > From Text/CSV, pick the file and choose Import.
- In the preview, check the Delimiter is right, then choose Transform Data.
- Select the heading of a column that holds codes, IDs, phone numbers or barcodes. Ctrl+click to add more.
- Choose Home > Data Type > Text. When asked, choose Replace current.
- Choose Home > Close & Load.
Replace current matters. Power Query has already guessed each column's type, and if it guessed a number, the zeros are gone before a later step could make the column text. It guesses from the first 200 rows, so check every column. These are the steps in Microsoft's guide to keeping leading zeros and large numbers.
For a quick way round, set Data Type Detection to Do not detect data types in the preview. Every column then arrives as text, including amounts you want to add up, so set those back to a number type in Transform Data.
2. The Text Import Wizard
Good for: older versions of Excel for Windows, and one-off imports.
The quickest way in is to rename the file from .csv to .txt and open it from Excel: as Microsoft's guide to importing text files explains, a .txt file starts the wizard, while a .csv opens straight away. If you can't see .csv at the end of the name, turn on file name extensions in File Explorer's View menu.
Or turn the wizard on: choose File > Options > Data, tick From Text (Legacy) under Show legacy data import wizards, then use Data > Get Data > Legacy Wizards > From Text (Legacy). Then:
- Step 1: choose Delimited. If the file is UTF-8, set File origin to 65001: Unicode (UTF-8).
- Step 2: tick the separator the file uses, usually Comma.
- Step 3: click each code column in the preview and choose Text. For dates, choose Date and the order they're written in.
- Choose Finish.
The limits: you set every column by hand, every time. And in our test, a note with a line break inside quotes was split across two rows. From Text/CSV can keep such notes in one cell: in Transform Data, open the Source step's settings (the gear icon under Applied Steps) and set Line breaks to Ignore quoted line breaks.
3. Excel's automatic data conversion settings
Good for: Excel for Microsoft 365 or Excel 2024, on Windows or Mac, if you double-click CSV files often.
On Windows, choose File > Options > Data and find Automatic Data Conversion. On a Mac, choose Excel > Preferences > Edit. Microsoft's page on setting automatic data conversions lists four switches: removing leading zeros, cutting numbers of 16 or more digits to 15, reading an E as scientific notation (123E5), and turning letters followed by numbers (JAN1) into dates. Another option warns you about them when you open a .csv file.
The limits are worth knowing. A 13-digit barcode or a +44 phone number isn't covered by any of the four, so it still shows as 5.01235E+12. Sizes such as 1-2 and fractions such as 3/4 still become dates, and Microsoft says values like JAN-1 may too. The settings don't apply to Power Query imports. And they only change your copy of Excel: a colleague who opens the same file still loses the zeros.
4. Repair a file you've already opened
Good for: when Excel has changed the values but you haven't saved over the CSV.
- Numbers of 12 to 15 digits, such as barcodes, are only displayed in scientific notation, and every digit is still there. Select the column, press Ctrl+1 and choose Number with 0 decimal places.
- Codes that are all the same length can get their zeros back with a formula. For six-digit codes,
=TEXT(A2, "000000")turns 7 back into 000007. It can't help when the lengths differ, because 007 and 0007 both became 7. - Numbers longer than 15 digits can't be repaired. Close without saving and import again with method 1 or 2.
Dates and £ signs go wrong in their own ways: see why Excel shows CSV dates wrongly or garbles £ signs.
When a tool is quicker
Each free method works, but you have to know which columns are at risk and set them one at a time, for every file. So does everyone you send it to.
That's why we made CSV to Sheet. Drop in a CSV and it shows which columns Excel would change and how: leading zeros removed, barcodes in scientific notation, digits lost, sizes turned into dates. Codes, IDs, phone numbers and barcodes stay as text, money becomes numbers you can add up, and dates become real dates, and you can change any column. Download a spreadsheet that opens the same for everyone, or a clean UTF-8 CSV for uploading. It runs in your browser on Windows or Mac, and your files never leave your computer. The free version converts the first 1,000 rows of each file; Pro is £15 once. You can try it with a sample file.
Quick answers
Why does Excel remove leading zeros from a CSV? It reads anything that looks like a number as a number. Import the file with Data > From Text/CSV and set those columns to Text.
How do I stop Excel showing long numbers as 1.23E+15? Import the column as text. If the numbers have 15 digits or fewer and you haven't saved, format the column as Number with no decimal places. Digits beyond the 15th are lost on opening.
Can I stop Excel doing this for good? Partly. Excel for Microsoft 365 and Excel 2024 can stop four of the changes, but not barcodes in scientific notation or sizes such as 1-2 becoming dates, and only on your own computer.