CSV to HTML table conversion for data files
This CSV to HTML converter is built for files: exports, reports and datasets saved as .csv. It parses the file with a real CSV parser, including delimiter detection and quoted fields, and writes a semantic table with <thead> for the header row and <tbody> for the data. The Preview tab renders the table next to the code, so you can see it before pasting it into a page.
Example
Station,Temp (°C),Rain (mm)
Oslo <Blindern>,4.0,1.2
Bergen,7.5,11.0
With Styling set to No CSS, the output is only the table:
<table>
<thead>
<tr>
<th>Station</th>
<th>Temp (°C)</th>
<th>Rain (mm)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Oslo <Blindern></td>
<td>4</td>
<td>1.2</td>
</tr>
<tr>
<td>Bergen</td>
<td>7.5</td>
<td>11</td>
</tr>
</tbody>
</table>
The angle brackets in the station name were escaped, so the value shows as text instead of being treated as a tag. The numbers 4.0 and 11.0 lost their trailing zeros because Detect numbers & booleans was on. For published figures with a fixed number of decimals, untick that option and the cells are copied exactly.
Layout: flat or nested tables
The Layout option decides how records with structure are drawn:
- Auto (default) – a single flat table for ordinary CSV, nested tables only when records contain objects or lists.
- Single flat table – always one table; nested fields are spread over dotted columns such as
roles.0. - Nested tables – lists become bulleted lists and objects become small key/value tables inside a cell.
Plain CSV only contains nested data when Nest dotted headers is ticked. Then a file like this:
id,name,roles.0,roles.1,manager.name
1,Ana,admin,dev,Leo
renders in Auto layout as:
<tr><td>1</td><td>Ana</td><td><ul><li>admin</li><li>dev</li></ul></td><td><table><tbody><tr><th>name</th><td>Leo</td></tr></tbody></table></td></tr>
That is handy for documentation pages where a list of roles reads better than numbered columns.
Styling options
No CSS gives bare markup that inherits your site's table styles. Bordered and Striped rows put a small <style> block above the table with collapsed borders, cell padding, a blue header row with white text and a hover highlight; the striped variant also shades every second row. The CSS uses plain table, th and td selectors, so on a page with other tables you may want to scope it before publishing.
Publishing the table
Most content management systems have a block or mode for raw HTML, such as the Custom HTML block in WordPress; paste the output there rather than into the visual editor, which may rewrite it. A few tips make the table easier to use:
- Add a
<caption>right after the opening<table>tag to describe the data. Screen readers announce it, and it helps readers who skim. - Keep the header row. The converter puts it in
<thead>with<th>cells, which browsers and assistive technology use to label each column. - For wide data, wrap the table in a container that scrolls horizontally on phones.
- For thousands of rows, consider showing a summary and offering the CSV as a download instead of one very long page.
Which HTML table tool to use
This site has three table-to-HTML tools, each for a different starting point:
- CSV to HTML (this page) – for CSV files, with delimiter control, typed parsing, dotted-header nesting and a nested layout.
- Table to HTML – accepts CSV, TSV, JSON or a Markdown table, and adds a CSS class and header colour so the table fits your own stylesheet.
- Tableizer – for cells pasted from Excel or Google Sheets, keeping every value exactly as shown and letting you set the font and size.
If you only need to look at a CSV rather than publish it, the CSV viewer is quicker.
Common issues
- All values in one column – set the Delimiter explicitly; semicolon-separated exports are common in Europe.
- An error with a record number – a quoted value is not closed. Fix that line and convert again.
- Headers look like column2 – the header row had empty cells, which are named by position.
Privacy
Your CSV is turned into HTML inside the browser and is not transmitted, except when you load it by URL or save a share link, both of which go through our server.
Convert CSV to an HTML table in Python
Two standard-library modules cover this: csv parses the rows and html escapes the cell text. Do not split the lines on commas yourself, because a quoted field such as "Bob, Jr." contains one. The step people skip is html.escape(): without it a value like R&D, or any cell containing <, is written into the table as raw markup.
import csv
import html
import io
data = 'name,team\nAnn,R&D\n"Bob, Jr.",Sales\n'
header, *body = csv.reader(io.StringIO(data))
def tr(cells, tag):
cells = "".join(f"<{tag}>{html.escape(cell)}</{tag}>" for cell in cells)
return f"<tr>{cells}</tr>"
lines = ["<table>", "<thead>", tr(header, "th"), "</thead>", "<tbody>"]
lines += [tr(row, "td") for row in body]
lines += ["</tbody>", "</table>"]
print("\n".join(lines))
Paste the same CSV into the converter above to compare your script's table with the tool's output.