All tools
Free · Private · No upload

Convert HTML Table to LaTeX Online

Convert an HTML table into a LaTeX tabular. The markup is read in your browser and never uploaded.

Drop a CSV or Excel file here

CSV · XLSX · XLS · XLSM · XLSB

or paste your data below

How to convert an HTML table to LaTeX

Three steps from prices.html to LaTeX.

1. Paste the HTML

Paste markup that contains a <table>, or drop an .html file.

2. Check it in the grid

Fix any cells shifted by colspan or rowspan, then pick the alignment: Right suits a price column.

3. Choose environment and rules

tabular or longtable, booktabs rules or grid lines, alignment and escaping; copy the code or download data.tex.

Example: HTML in, LaTeX out

A price table with dollar signs, a percent sign, an &amp; entity and an &mdash; entity.

prices.html
<table>
  <tr><th>Item</th><th>Price</th><th>Discount</th></tr>
  <tr><td>Desk lamp</td><td>$24.00</td><td>10%</td></tr>
  <tr><td>Chair &amp; cushion</td><td>$89.50</td><td>&mdash;</td></tr>
</table>
data.tex (default options)
\begin{tabular}{|l|l|l|}
\hline
Item & Price & Discount \\
\hline
Desk lamp & \$24.00 & 10\% \\
Chair \& cushion & \$89.50 & — \\
\hline
\end{tabular}

$ and % are special in LaTeX, so $24.00 is written as \$24.00 and 10% as 10\%; the decoded & in Chair & cushion becomes \&. The &mdash; arrives as an em dash character, which LaTeX handles with its default UTF-8 input (since 2018).

What changes between HTML and LaTeX

Escaping

& % $ # _ { } ~ ^ are escaped, so the value $24.00 is written as \$24.00. Untick Escape special chars only when the cells already contain LaTeX, such as math in $...$.

booktabs

Tick booktabs for \toprule, \midrule and \bottomrule and no vertical lines, the style most journals ask for. A comment above the table reminds you to load \usepackage{booktabs}.

Text content only

Each cell's text is taken, trimmed. Tags inside cells, such as links or <b>, are dropped and entities are decoded, so &amp; and &mdash; arrive as the characters they stand for.

When to convert HTML to LaTeX

HTML to LaTeX in JavaScript

TabularJS reads HTML: every <table> becomes a worksheet. Then special characters are escaped and cells joined with &.

import tabularjs from 'tabularjs';

// The first row of the table becomes the column titles
const { worksheets } = await tabularjs('prices.html', { tableIndex: 0 });
const ENT = { amp: '&', mdash: '\u2014' }; // Node.js keeps entities as written
const decode = (v) => String(v ?? '').replace(/&(\w+);/g, (m, e) => ENT[e] ?? m);
const header = worksheets[0].columns.map((col) => decode(col.title));
const rows = worksheets[0].data.map((row) => row.map(decode));

const map = { '\\': '\\textbackslash{}', '~': '\\textasciitilde{}', '^': '\\textasciicircum{}' };
const esc = (v) => String(v ?? '').replace(/[\\&%$#_{}~^]/g, (c) => map[c] ?? '\\' + c);
const line = (cells) => cells.map(esc).join(' & ') + ' \\\\';
console.log([`\\begin{tabular}{|${header.map(() => 'l').join('|')}|}`, '\\hline', line(header), '\\hline',
  ...rows.map((row) => line(header.map((_, i) => row[i]))), '\\hline', '\\end{tabular}'].join('\n'));

TabularJS differs from this page in two ways: it returns every <table> as a worksheet, and it turns colspan into mergeCells. In Node.js it leaves entities such as &amp; as written, hence the decode step.

npm install tabularjs MIT licensed

Frequently asked questions

Can colspan become \multicolumn?

No. Spans aren't read from the HTML, so every cell becomes an ordinary column. Add \multicolumn by hand where you need it.

Will the em dash print?

Yes. It arrives as the — character, which LaTeX's default UTF-8 input prints as an em dash. You can also replace it with --- in the grid.

Does JavaScript in the pasted page run?

No. The markup is parsed as an inert document: scripts are not executed and nothing is fetched. Only the table text is read.

How do I get rid of the vertical lines?

Tick booktabs: the column spec loses its | separators and the rules become \toprule, \midrule and \bottomrule. Without booktabs, delete the | characters from the spec by hand.

Does prices.html get uploaded when I convert it to LaTeX?

No. The markup is read in your browser and never uploaded.