Boneyard Tools

CSV to HTML Table Converter

Paste comma-separated data and get a ready-to-embed HTML table built from it. The parser follows RFC 4180, so quoted fields, commas and line breaks inside quotes, and doubled escape quotes all land in the right cell. Every value is HTML-escaped, and you can toggle a header row, add a table class and switch between indented and minified markup.

How to convert CSV to an HTML table

  1. Paste or type your data into the CSV data box, or click Load sample to see the format.
  2. Leave First row is a header checked to render the top row as th cells, or uncheck it for an all-td table.
  3. Keep Pretty-print on for indented HTML, or turn it off for one minified line.
  4. Optionally type a name in the Table class field to add a class attribute to the table tag.
  5. Click Copy to grab the markup, or Download to save it as table.html.

Examples

Header row with body rows

Name,Role
Ada,Engineer
Linus,Maintainer
<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Role</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Ada</td>
      <td>Engineer</td>
    </tr>
    <tr>
      <td>Linus</td>
      <td>Maintainer</td>
    </tr>
  </tbody>
</table>

Comma inside a quoted field stays one cell

Fruit,Note
Fig,"Sweet, dried"
<table>
  <thead>
    <tr>
      <th>Fruit</th>
      <th>Note</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Fig</td>
      <td>Sweet, dried</td>
    </tr>
  </tbody>
</table>

Minified output with Pretty-print off

a,b
1,2
<table><thead><tr><th>a</th><th>b</th></tr></thead><tbody><tr><td>1</td><td>2</td></tr></tbody></table>

Frequently asked questions

Does it handle commas inside quoted fields?

Yes. A field wrapped in double quotes can contain commas, line breaks and escaped quotes written as two double quotes, and the parser keeps it as one cell. In the Fig example above, the comma inside the quotes never splits Sweet, dried into two columns.

Is the generated HTML safe to paste anywhere?

Yes. Every cell is escaped, so <, >, &, double quotes and single quotes become &lt;, &gt;, &amp;, &quot; and &#39;. That means data cannot break out of a cell or inject elements, and the table class you enter is escaped the same way.

What happens to a line break inside a cell?

A hard line break inside a quoted field is converted to a br tag, so a multiline cell still renders on separate lines in the rendered table instead of collapsing into one run of text.

What if my data has no header row?

Uncheck First row is a header. Every row is then rendered inside tbody as td cells with no thead section, which suits data that starts straight away with values.

Can I add a CSS class to the table?

Yes. Type a name into the Table class field and it is added to the opening tag as class="yourname", so you can target it from your own stylesheet. Leave it blank to get a plain table tag.

What does Pretty-print do to the output?

On, the markup is indented with two spaces and one tag per line, which is easy to read and diff. Off, the whole table is emitted as a single line with no whitespace between tags, which is smaller to ship.

How are ragged rows with different column counts handled?

Rows are padded to the width of the widest row, so short rows gain empty td cells and the table stays rectangular. No cell is dropped and no row is left with a missing column.

Can I get Markdown or JSON instead of HTML?

For a Markdown pipe table use the CSV to Markdown tool, and to turn the same data into structured records use CSV to JSON. This converter is focused on producing table markup for web pages and emails.

Is my data private?

Yes. Parsing and rendering run entirely in your browser, so the CSV you paste is never uploaded to a server.

Learn more

Related tools