All tools
Free · Private · No upload

Convert HTML Table to PDF Online

Turn an HTML table into a PDF with a clean, consistent table layout. 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 PDF

Three steps from timetable.html to a PDF.

1. Paste the HTML

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

2. Check it in the grid

Delete columns you don't need on paper, and choose Landscape if the table is wide.

3. Download PDF

Pick Portrait or Landscape and click Download PDF. data.pdf is generated in your browser.

Example: HTML in, PDF out

A bus timetable with a <caption> above the rows and two times in some cells.

timetable.html
<table>
  <caption>Route 12</caption>
  <tr><th>Stop</th><th>Mon–Fri</th><th>Sat</th></tr>
  <tr><td>Central</td><td>07:00, 07:30</td><td>08:00</td></tr>
  <tr><td>Harbour</td><td>07:12, 07:42</td><td>08:12</td></tr>
</table>
data.pdf (header row printed as the table head)
StopMon–FriSat
Central07:00, 07:3008:00
Harbour07:12, 07:4208:12

The <caption> is not a table row, so "Route 12" is not printed. The page's CSS, images and links are not part of the PDF either; use the browser's Print to PDF if you need the page exactly as it looks.

What changes between HTML and PDF

Page layout

The table is drawn on A4 pages, portrait or landscape. The header row (Stop, Mon–Fri, Sat) is printed as a coloured table head and repeated at the top of every page; body rows are striped.

Text, not an image

Values are printed as text, as they appear in the grid, so the PDF can be searched and copied from. Long values wrap inside their column and widths are set automatically.

First row is the header

The first row (Stop, Mon–Fri and Sat) becomes the header, whether its cells are <th> or <td>. colspan and rowspan would not be expanded, so check spanned rows in the grid.

When to convert HTML to PDF

HTML to PDF in JavaScript

TabularJS reads HTML: every <table> becomes a worksheet. Then jsPDF and jspdf-autotable, the libraries this page uses, draw the table.

import { writeFile } from 'node:fs/promises';
import tabularjs from 'tabularjs';
import { jsPDF } from 'jspdf';
import { applyPlugin } from 'jspdf-autotable';

// The first row of the table becomes the column titles
const { worksheets } = await tabularjs('timetable.html', { tableIndex: 0 });
const header = worksheets[0].columns.map((col) => col.title);
const rows = worksheets[0].data;

applyPlugin(jsPDF); // adds doc.autoTable()
const doc = new jsPDF({ orientation: 'landscape' });
doc.autoTable({ head: [header], body: rows.map((row) => header.map((_, i) => String(row[i] ?? ''))) });
await writeFile('timetable.pdf', Buffer.from(doc.output('arraybuffer')));

TabularJS differs from this page in two ways: it returns every <table> as a worksheet, and it turns colspan into mergeCells.

npm install tabularjs MIT licensed

Frequently asked questions

Why not print the web page to PDF?

Browser printing keeps the page's layout, navigation and styles, and wide tables are often cut off. This gives you only the table, with the header repeated on each page.

Can the caption be added back?

Not on this page. In code, call doc.text() with the caption before autoTable, as a title above the table.

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.

Can I copy text from the PDF?

Yes. The table is real text, not an image, so you can search it and copy from it in any PDF reader.

Does timetable.html get uploaded when I convert it to PDF?

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