CSV to Excel Converter
Convert any CSV or TSV to a real .xlsx workbook entirely in your browser. Comma, semicolon, tab, and pipe delimiters auto-detect; numeric and date columns are typed correctly so SUM and sort work out of the box; Sinhala and Tamil text round-trip cleanly. No upload, no signup, sources cited.
How it works
An .xlsx file is a ZIP archive containing a small set of XML parts known as the SpreadsheetML format (ECMA-376 5th Ed., Part 1 §18). The minimum set is a content-types manifest, two relationship files, a workbook descriptor, a styles sheet, and one worksheet XML containing the cells. This tool writes each of those parts by hand and packs them into a ZIP using fflate. Everything happens in the browser.
For each CSV the tool runs five deterministic steps:
- Decode the bytes. The file is read as UTF-8 text via the File API. A leading byte-order mark (EF BB BF) is detected and stripped so it doesn't end up in the first field. Non-ASCII text (Sinhala, Tamil, emoji) is preserved byte-for-byte through the pipeline.
- Detect the delimiter. The first 20 non-empty lines are scored against four candidates — comma, semicolon, tab, and pipe. For each candidate the tokenizer counts fields per line (respecting quoted segments per RFC 4180 §2.5), then ranks by
average − variance. A perfect tabular file has zero variance, so the right delimiter wins. - Parse. A single-pass state machine walks the bytes, honouring RFC 4180 quoting and double-quote-inside-a-quoted-field escapes, with tolerance for CR-only and LF-only line endings. The parser is cross-checked by
serializeCsv(parseCsv(text))— a round trip must reproduce the input's logical rows. - Infer column types. For each column, the non-empty cells are tested against a strict numeric regex (
/^-?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/), an ISO 8601 date regex (YYYY-MM-DD) with calendar validation, and a boolean literal check (true / false, case-insensitive). A column is typed only if every non-empty value agrees — anything heterogeneous falls back to text. This keeps long identifiers (NIC numbers, phone numbers, ISBNs) out of scientific-notation hell. - Assemble the .xlsx. Each row of the worksheet becomes a
<row>element with one<c>per non-empty cell. The cell coordinate (A1, B7, AB12, XFD1) is generated by a base-26-no-zero algorithm and cross-checked by an alternate tier-decomposition formula — the two must agree on every value from 0 to 16,383 (XFD). Dates are written as Excel serial numbers using the formula(date_utc − 1899-12-30) / 86_400_000, which matches Excel for every date from 1900-03-01 onward (the “phantom 1900-02-29” bug is documented by Microsoft and intentionally preserved by every spreadsheet app). Strings are inlined as<is><t>…</t></is>, avoiding the extra round trip of a shared-string table for the file sizes we're likely to see in a browser.
The result is a Uint8Array of bytes that becomes a Blob of type application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, wrapped in an object URL and offered as a download. No bytes leave the tab.
Edge cases the parser handles
Real exports are rarely clean, so the pipeline is built around the awkward cases rather than the ideal one. A ragged CSV — rows with different field counts, common in hand-edited files — is padded to the widest row when written, so no cell shifts into the wrong column. A field that contains the delimiter, a line break, or a literal double-quote is round-tripped through RFC 4180 quoting, which is why a value like "Colombo 07, Sri Lanka" stays in one cell instead of splitting at the comma. Leading and trailing spaces are preserved with xml:space="preserve", so an account code like 0042 keeps its alignment. Mixed columns — a column that is mostly numbers but has one N/A — fall back to text rather than silently dropping the outlier, the single most common cause of corrupted spreadsheet imports.
A few shapes are deliberately left as text. Numbers with thousands separators (1,250,000) are not coerced, because the comma is ambiguous with the delimiter and a wrong guess is worse than a true value. Currency strings, percentages with a trailing %, and non-ISO dates stay as text so nothing is lost — you can format them inside Excel afterwards. If your source is messy enough that you want to tidy it first, run the rows through the sort lines or duplicate line remover tool before converting. And if your data started life as JSON rather than CSV, the JSON converter will flatten it to RFC 4180 CSV that this page reads directly.
Worked examples
Common workflows
Most CSVs that need converting come out of another program rather than a person: a bank statement export, a Shopify or WooCommerce order dump, a Google Forms response sheet, an SQL SELECT … INTO OUTFILE result, or a point-of-sale daily sales report. Each of those produces a flat text grid that opens awkwardly in Excel — dates as text, numbers misaligned, long IDs mangled into scientific notation. The fix is a typed conversion, which is exactly what this page does in one pass.
A typical workflow for a Sri Lankan small business looks like this: export the month's transactions from your billing software as a CSV, drop it here to get a clean .xlsx with real number and date columns, total the figures in Excel, then save the summary as a PDF to email to an accountant. The last step is a one-click job with the Excel to PDF converter, which preserves the column widths and number formatting this tool set up. Freelancers invoicing overseas clients often pair it with the freelancer USD–LKR calculator to convert a CSV of foreign-currency payments into rupee totals before filing.
Because the conversion is deterministic — the same CSV always yields byte-for-byte the same worksheet structure — you can rely on it inside a repeated monthly process without re-checking the output each time. And since nothing is uploaded, sensitive data (salaries, customer lists, NIC numbers) never leaves your laptop, which keeps the workflow compliant with the data-handling rules most Sri Lankan employers and banks now expect.
Frequently asked questions
Sources & references
- IETF RFC 4180 — Common Format and MIME Type for CSV Files
- ECMA-376 5th Edition — Office Open XML File Formats (SpreadsheetML)
- Microsoft — Excel specifications and limits (rows, columns, cell length)
- Microsoft — Date systems in Excel (1900 epoch and the 1900-02-29 quirk)
- Unicode FAQ — UTF-8 byte-order mark
- fflate — pure-JS ZIP encoder used to pack the OOXML parts
The CSV parser and .xlsx writer were cross-checked against the above standards on 2026-05-11. The page is reviewed whenever ECMA-376 publishes a new edition or Microsoft revises Excel's per-sheet limits.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.