DevTools Pro · All tools · About

HTML Table Generator

About the HTML Table Generator

Convert a table to HTML in seconds: paste cells copied from Excel or Google Sheets, CSV or a Markdown table, or type data into the editable grid, and this HTML table generator returns clean, accessible table markup with optional CSS, previewed live. Special characters are escaped for you, so the HTML is safe to paste into any page or CMS.

Anatomy of an HTML table

A well-structured table wraps the header row in <thead> and the data rows in <tbody>. Header cells use <th scope="col">, which tells screen readers that the cell labels the column below it. An optional <caption> gives the whole table a title.

The generator produces exactly this structure. With Header row turned off, every row goes into <tbody> as <td> cells, which suits simple layouts without column labels.

Pasting from Excel, Google Sheets or CSV

Copying cells in Excel or Google Sheets puts tab-separated text on the clipboard. The importer looks at the first line and picks the separator itself: a tab means spreadsheet text, otherwise a semicolon (when it outnumbers commas, or when each comma is a decimal comma as in 1,50) means semicolon CSV, otherwise a comma means standard CSV. A first line with a pipe and no tab is read as a Markdown table. Separators inside double quotes are ignored.

Quoted fields follow the usual CSV rules: "" inside quotes is a literal quote, and a line break inside quotes stays in the same cell and is written as <br> in the HTML. A leading tab is kept as an empty first cell, rows are padded to the same width, and a byte order mark at the start is ignored. Imports are capped at 50 rows by 50 columns.

The first imported row becomes the header while Header row is on. Turn it off to make every row a body row, with no <thead>.

Styling a table with CSS

With Include <style> block on, the output starts with a small stylesheet scoped to your CSS class. It sets border-collapse: collapse so adjacent borders merge into single lines, applies padding (horizontal padding is 1.5x the vertical value), and aligns text left, center or right.

Striped rows use tbody tr:nth-child(even) to shade every second row, which makes wide tables easier to scan. Turn the style block off if your site already styles tables or uses a framework like Bootstrap; you then get bare markup with just the class attribute.

When to use a table, and when not to

Tables are for tabular data: rows of records with the same columns, such as pricing, schedules or comparison charts. Do not use them to lay out a page; CSS Grid and Flexbox do that job and work better with screen readers and on small screens.

Wide tables overflow on phones. Wrap the table in a container with overflow-x: auto so it scrolls horizontally instead of breaking the layout.

How to Use the HTML Table Generator

  1. Paste cells copied from Excel or Google Sheets, a CSV or a Markdown table into Convert a table to HTML and press Import table (or Ctrl/Cmd+Enter). Click Example to see a sample, or type straight into the grid.
  2. Set Header row, Borders, Striped rows, Full width, Cell padding, Text align, Header background, CSS class and an optional Caption under Styling, or switch off Include <style> block for bare markup.
  3. Check the Preview, then click Copy or Download to save a complete table.html page. Clear cells empties the grid.

HTML Table Generator Examples

Paste from Excel or Google Sheets

Cells copied from a spreadsheet are tab-separated. The empty cell stays empty and 1,200 keeps its comma. Shown with Include <style> block switched off.

Input:

Region	Q1	Q2
North	1,200	1,450
South	980	

Output:

<table class="data-table">
  <thead>
    <tr>
      <th scope="col">Region</th>
      <th scope="col">Q1</th>
      <th scope="col">Q2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>North</td>
      <td>1,200</td>
      <td>1,450</td>
    </tr>
    <tr>
      <td>South</td>
      <td>980</td>
      <td></td>
    </tr>
  </tbody>
</table>

CSV with quoted commas, quotes and a line break

The comma in "Smith, John" stays in one cell, "" becomes a quote (escaped as &quot;) and the line break becomes <br>. Style block off.

Input:

name,notes,qty
"Smith, John","He said ""ok""
and left",3
Plain,text,4

Output:

<table class="data-table">
  <thead>
    <tr>
      <th scope="col">name</th>
      <th scope="col">notes</th>
      <th scope="col">qty</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Smith, John</td>
      <td>He said &quot;ok&quot;<br>and left</td>
      <td>3</td>
    </tr>
    <tr>
      <td>Plain</td>
      <td>text</td>
      <td>4</td>
    </tr>
  </tbody>
</table>

Semicolon CSV without a header row

European-style CSV with decimal commas is detected as semicolon-separated. With Header row off every row is a body row. Style block off.

Input:

Tea;1,50
Coffee;2,00

Output:

<table class="data-table">
  <tbody>
    <tr>
      <td>Tea</td>
      <td>1,50</td>
    </tr>
    <tr>
      <td>Coffee</td>
      <td>2,00</td>
    </tr>
  </tbody>
</table>

Common Errors

The whole row lands in one column after importing.
The separator was not the one found on the first line. Make sure the first line contains the tab, semicolon or comma that separates your columns, or copy the cells again from the spreadsheet.
A toast says "Nothing to import".
The paste box is empty or holds only blank lines. Paste the rows first, then press Import table.
Only 50 rows or columns appear after importing a large sheet.
Imports and the grid are limited to 50 by 50. Split the data into several tables.
The first data row became the header.
The first imported row is the header while Header row is on. Turn Header row off to get only <td> cells with no <thead>.
Cells show &amp; or &lt; in the HTML where you typed & or <.
This is correct escaping. Browsers display the original characters, so paste the HTML as it is.

Frequently Asked Questions

Is my table data uploaded anywhere?
No. The grid, the HTML and the preview are all generated in your browser. Nothing is sent to a server.
Can I paste a table from Excel or Google Sheets?
Yes. Select the cells in your spreadsheet, copy them, paste them into Convert a table to HTML and click Import table. Spreadsheets copy as tab-separated text, which the importer detects automatically; CSV (comma or semicolon) and Markdown tables work the same way.
How do I merge cells with colspan or rowspan?
Merging is not supported in the grid. Add colspan="2" or rowspan="2" to the relevant <td> in the copied HTML and delete the cells it replaces.
Will the CSS conflict with my site's styles?
The rules are scoped to the class you choose, data-table by default, so they only affect tables with that class. Rename the class if it clashes.
What happens to line breaks and quotes inside a cell?
Quoted fields in a CSV or spreadsheet paste keep their line breaks, which are written as <br> in the HTML, and "" inside quotes becomes a single quote character that is then escaped as &quot;. In the editable grid a line break is not shown, so retype that cell only if you need to change it.

Related tools