DevKitHub

JSON & Data

CSV to Excel Converter — Keep Leading Zeros, IDs and Codes Intact

Paste CSV to download an .xlsx workbook in which every value looks the way it does in the file. Numbers become numbers; anything Excel would have mangled stays text.

3 lines

Workbook

Table
2 rows × 6 columns, plus a header row
Delimiter
comma, detected
Cells
7 text cells · 5 numbers
Kept as written
11 values that opening the CSV in Excel would have changed
File size
2.8 KB .xlsx
  • 007 stays as written; Excel would make it 7
  • 4006381333931 stays as written; Excel would make it 4.00638E+12 on screen
  • 1-2 stays as written; Excel would make it a date
  • 12.50 stays as written; Excel would make it 12.5
  • +441234567890 stays as written; Excel would make it 441234567890
  • and 6 more

Preview of Sheet1

The first rows of the sheet as Excel will show them: numbers and dates right-aligned, text left-aligned.
skubarcodephonesizepricezip
0074006381333931079111234561-212.5002134
0425012345678900+4412345678903/40.1010001

Numbers and dates are right-aligned and text left-aligned, as Excel aligns them.

Open the downloaded .xlsx rather than the CSV: its cells are typed, so Excel has nothing to guess. The file is built in this page and never uploaded. For the reverse, Excel to CSV writes stored values rather than formatted ones.

This tool runs entirely in your browser. Your input is never uploaded, stored or logged.

How it works

A CSV file has no types: every field is text, and whatever opens it has to guess. Excel guesses as it opens the file, and the guesses destroy data. Opened in Excel for Mac, a CSV holding 007 showed 7; +441234567890 became the number 441234567890; 1-2, 3/4 and the gene name SEPT2 became dates; 1e5 became 100000 and 1 1/2 became 1.5; =1+2 became a formula; and a 20-digit id kept its first 15 digits and turned the rest into zeros, because Excel holds 15 significant digits. Saving the CSV again writes the damage back into the file. Recent Microsoft 365 versions let you switch some of these conversions off under Automatic Data Conversion, but 1-2 and 3/4 still become dates, and the person you send the file to has their own settings. An .xlsx does not have the problem at all, because each cell carries its type, and a cell marked as text is shown as text whatever it contains.

The CSV is read with the same RFC 4180 scanner as CSV to JSON — a quoted field may hold the delimiter, line breaks, and "" for a literal quote — and on Auto the delimiter is whichever of comma, semicolon, tab or pipe appears most in the first line. Then each field is typed cautiously. It becomes a number only if it is a plain decimal with no leading zero, plus sign, exponent or thousands separator, and at most 15 significant digits; everything else is written as text, character for character, and the values Excel would have changed are counted, with examples. Numbers keep their appearance too: 12.50 is stored as 12.5 with a 0.00 format, and a 13-digit barcode gets a 0 format so it is not shown as 4.00638E+12. ISO 8601 dates become Excel dates only if you turn that on, and 03/04/2026 never does, because it is 3 April in one country and 4 March in another.

Excel’s own Save As CSV makes a good test of the result, because it writes each cell as it is displayed: opening a workbook from this converter in Excel and saving it as CSV gave back the original file field for field. The header row is bold and frozen, column widths are estimated from the content, and the workbook is written without a library — sheet XML, a shared string table, number formats and a DEFLATE-compressed ZIP, all in this page. Numbers with thousands separators, such as 1,234.50, stay text, because the comma is the decimal mark in much of Europe; Excel’s Data > Text to Columns converts them with the separators you choose.

Common problems

Every example below is run against this tool in our test suite, so what it says here is what the tool actually does.

A quoted field was never closed.

id,name
1,"Ada
Why:
A field that opens with a quote runs until the next lone quote, across commas and line breaks, so one missing quote swallows the rest of the file.
Fix:
Close the quote. A literal quote inside a quoted field is written twice, as in "say ""hi""".

Opening the CSV in Excel turned 007 into 7 and 1-2 into a date.

Why:
Excel guesses a type for every CSV field when it opens the file, and there is no type information to stop it. The .xlsx written here stores those values as text cells, so there is nothing to guess.
Fix:
Open the .xlsx this page writes instead of the CSV. The list of kept values shows what Excel would have changed.

All the data is in column A.

Why:
The delimiter was not the one the file uses. Auto looks only at the first line, so a title line above the header, with no separators in it, makes it choose a comma.
Fix:
Choose the delimiter by hand, or delete the title line so the header row comes first.

Amounts like 1,234.50 are text in the workbook.

Why:
A thousands separator is read differently by locale — 1,234 is one thousand two hundred and thirty-four in the UK and one point two three four in Germany — so such values are kept as written rather than guessed at.
Fix:
Export the CSV without thousands separators, or convert the column in Excel with Data > Text to Columns, choosing the separators.

Frequently asked questions

How do I open a CSV in Excel without losing leading zeros?
Convert it to .xlsx here and open that instead. Each value Excel would have changed — leading zeros, long ids, codes that look like dates — is stored as a text cell, so Excel shows it as written.
Is my CSV uploaded?
No. The CSV is parsed and the .xlsx is built by JavaScript in this page, including the ZIP compression, and the file is handed to your browser as a download.
Are numbers still numbers in the Excel file?
Plain numbers are, so they sum and sort. A number keeps the look it had, such as 12.50 with two decimals. Only values that would change on the way in, such as 007, stay text; Detect numbers off keeps everything as text.
What about dates?
ISO 8601 dates such as 2026-09-29 become Excel dates when ISO dates is on. Other date styles stay text, because 03/04/2026 means different days in different countries and the file does not say which.

Last updated