HTML Table Generator
Create HTML table code from an editable grid or pasted CSV, with caption, header cells, th scope, CSS class or inline styles, and a live preview.
Press Enter to move down a row. Paste cells copied from a spreadsheet into any cell to fill the grid from there.
Preview
How to generate an HTML table
- Fill in the grid. Use Add row, Add column, Remove last row and Remove last column, or the × buttons next to each row and column. New empty table starts again from a blank 3 × 3 grid.
- To reuse existing data, paste CSV or cells copied from Excel, LibreOffice or Google Sheets into Import CSV or spreadsheet data, check the Delimiter and click Import. You can also paste a block of spreadsheet cells straight into any grid cell.
- Add a Caption and choose whether First row is a header row and First column is a header column.
- Under Styling, pick No styles, CSS class or Inline styles, and adjust the Border color, Header background and Striped rows if you want.
- Check the Preview, then click Copy HTML or download the code as an
.htmlfile.
Accessible table markup
A table is only accessible when screen readers can tell which cells are headers and what they describe. This tool writes the structure that the HTML standard and the WCAG techniques recommend:
<caption>gives the table a name. Screen readers announce it when entering the table, and it helps every reader understand what they are looking at. Keep it short and descriptive.<thead>and<tbody>separate the header row from the data rows. Browsers can repeat the<thead>on every printed page.<th scope="col">marks each column header, and with First column is a header column,<th scope="row">marks the first cell of each row. When a screen reader user moves to a data cell, it can read the matching headers aloud, such as “Pro, Price, $12”.
Use tables for tabular data only, never for page layout. Avoid merged cells when you can: simple grids with one header row and, if needed, one header column are the easiest to read with assistive technology.
Styling options
- No styles writes plain markup that inherits your site’s table styles. It is the best choice for a CMS or a site with a design system.
- CSS class adds
class="…"to the<table>and shows a matching block of CSS to paste into your stylesheet. The Class name is cleaned to letters, digits, hyphens and underscores so it is always a valid selector. - Inline styles puts
styleattributes on every element. It is verbose, but it is what HTML emails need, since many email clients ignore<style>blocks. The Download button adds the CSS in a<style>element when you use a class.
Only real hexadecimal colors from the color pickers are written into the CSS, so nothing unexpected can end up in your styles.
Escaping and safety
Every cell is escaped: <, > and & become <, > and &, so text such as <b> or a < b appears exactly as typed instead of being interpreted as markup. Line breaks inside imported cells become <br>. The preview is built only from this escaped markup and passes through a sanitizer that keeps table elements alone, so a pasted script can never run.
Frequently asked questions
Can I put links or bold text in a cell?
Not from the grid: cell content is always escaped, which keeps the code valid and safe. Add links or formatting to the generated code afterwards if you need them.
Why use a caption instead of a heading above the table?
A <caption> is tied to the table in the accessibility tree, so screen readers announce it with the table. A heading above it is not linked to the table.
Does the tool support merged cells (colspan and rowspan)?
No. The grid produces one cell per position. Merged cells make tables harder to read for assistive technology, so keep them for cases where they are really needed and add them by hand.
Is my data uploaded?
No. The grid, the import, the code and the preview are all produced in your browser. Nothing you paste is sent to a server.
How big can the table be?
The grid holds up to 500 rows and 30 columns. For bigger datasets, a sortable data grid or a downloadable CSV file is usually more useful than a static HTML table.
Related tools
- Markdown Table Generator Build Markdown tables in a grid, paste CSV or spreadsheet cells, set column alignment and copy a neatly aligned GitHub Flavored Markdown table.
- HTML Formatter Beautify messy HTML with clean indentation, or minify it safely, in your browser. Inline CSS and JavaScript are formatted too. Nothing is uploaded.
- HTML Entity Encoder/Decoder Escape special characters as HTML entities (named, decimal or hex) or decode any entity, using the full list of 2,231 HTML5 named references.