CSV to HTML Table

An HTML table from a CSV file or from text you paste. The first row becomes the table’s header, every value is escaped so a stray angle bracket or ampersand cannot break your page, and an address written on three lines stays on three lines. Copy just the table code to paste into your website or blog, or save a whole page with the styling done that opens in any browser. A Thai file exported from Excel is read in whatever encoding Excel wrote it in, and nothing leaves your browser.

1 · The CSV

2 · Options

Turn this off if the first row is data.

What you get

3 · The result

Drop a CSV file or paste the text to begin.

An example: this CSV becomes this table

Three lines of CSV, the second with a comma inside quotation marks:

name,phone,city
Somchai Jaidee,0812345678,"Chiang Mai, Chang Khlan"
Mali Rakthai,0898765432,Phuket

and the table code this page writes for it, with the first row as the header:

<table>
  <thead>
    <tr><th>name</th><th>phone</th><th>city</th></tr>
  </thead>
  <tbody>
    <tr><td>Somchai Jaidee</td><td>0812345678</td><td>Chiang Mai, Chang Khlan</td></tr>
    <tr><td>Mali Rakthai</td><td>0898765432</td><td>Phuket</td></tr>
  </tbody>
</table>

The quoted comma stays inside its cell, the phone numbers keep their zero, and nothing needs cleaning up before it goes into a page.

What each tag in the table is for

TagWhat it does
<table>The table itself; everything else sits inside it.
<thead>The header rows. Screen readers announce these as column names, and a long printed table repeats them on every page.
<tbody>The data rows.
<tr>One row, from one line of the CSV.
<th>A header cell: a column name from the first row.
<td>An ordinary cell: one value.
<br>A line break inside a cell, where the CSV value had one.

Putting the table into WordPress, Blogger or Google Sites

  • WordPress: add a Custom HTML block and paste the table code into it.
  • Blogger: switch the post editor to HTML view, paste where the table should go, and switch back.
  • Google Sites: choose Embed, then Embed code, and paste the whole styled page, which carries its own look.

Paste only the table where the site already has a style you want the table to follow, and the whole page where it has none.

Frequently asked questions

How do I turn a CSV into an HTML table?

Drop the file on the box above, or paste its text. The table is written straight away: the first row becomes the table’s header, marked as one so screen readers and search engines know it, and the rest become its rows. Copy the code or download it as an .html file. If your first row is data rather than column names, untick that option and every row is written as an ordinary row.

Should I take just the table or the whole page?

Just the table when it is going into a page that already exists: a WordPress post, a Blogger entry, a template of your own. It carries no styling, so it takes on your site’s. The whole page when the table is the thing you are sending: it is a complete .html file with the styling in it, opens in any browser on any device, and can be emailed or put on a shared drive as it is.

Can the table look good without writing CSS?

Choose the whole page. It has striped rows, a header that stays at the top while you scroll a long table, columns of numbers aligned to the right so the digits line up, a font that renders Thai properly, sideways scrolling on a phone instead of a squashed table, and a dark version for people who use dark mode. The styling is in one style block at the top of the file, so you can copy it into your own site too.

My CSV has Thai in it and other converters show it as symbols.

A CSV does not say what it is written in, so every reader guesses. This one measures instead: UTF-8, UTF-8 with a byte-order mark (Excel’s "CSV UTF-8"), Windows-874 (Excel’s ordinary CSV on a Thai computer) and UTF-16 (Excel’s "Unicode Text") are all recognised, and the page says which it found. The table is always written in UTF-8 and the whole page declares it, so it shows correctly wherever it is opened.

A cell contains angle brackets, an ampersand or a piece of code. Will it break my page?

No. Every value is escaped, so a bold tag typed into a cell appears as the characters themselves rather than turning the rest of the table bold, and a cell containing a script tag is text that cannot run. This matters most when the CSV came from somewhere else, such as a form or an export, because that is where values nobody checked come from.

Is my file uploaded?

No. The file is read by your browser and the table is written by your browser. The site’s security policy sets connect-src ‘none’, so the browser blocks network requests from these pages, so nothing could be sent even if the code tried. Most sites on the first page of results for this upload the file to a server, and some say they delete it after a day.

How large a file can it take?

Any size. The file is read a piece at a time and the table is written a piece at a time, so a file larger than your computer’s memory is fine. The page shows the first 200 KB of the result so it stays quick; the download has all of it. The Copy button is there for results up to 8 MB, because a clipboard is not meant to hold a file.

I wanted the CSV as a table in Excel, not on a web page.

That is a different job, and there is a page for it on this site: CSV to Excel writes a real .xlsx where phone numbers keep their leading zero and long ID numbers are not turned into 1.2E+12.