SQL to HTML

Paste a dump of INSERT statements and get a table you can drop into a page or a report.

SQL inserts
HTML
Runs locally in your browser

About the SQL to HTML

Sharing query results with somebody who has no database client usually means a screenshot. This converter reads the INSERT statements from a dump, pulls the column list and the value tuples out of them, and writes a proper HTML table: a thead with scope attributes on the header cells, a tbody with one row per tuple, and a caption naming the table it came from.

Cell contents are escaped, so a value containing < or an ampersand renders as text rather than breaking the markup. Doubled single quotes inside a string literal, the SQL way of writing an apostrophe, are collapsed back to one character. NULL is rendered with a label you choose, since an empty cell and a missing value are not the same thing to a reader.

Three outputs suit three jobs. The table markup on its own is what you paste into an existing page or a content management system. The full page wraps it in a document with borders, header shading and optional zebra striping, ready to open in a browser or email as an attachment. The rendered preview shows the finished table in place so you can check the columns before copying anything.

Several INSERT statements against different tables produce several tables, one after another. For a spreadsheet instead of a page, use SQL to CSV, and for a data structure use SQL to JSON.

How to use

  1. Paste the INSERT statements, or press Sample to load a station list.
  2. Choose whether you want the table markup, a full page or a rendered preview.
  3. Set the caption and the text that should stand in for NULL.
  4. Copy the markup, or download table.html.

Common questions

What kind of SQL does it read?
INSERT INTO ... VALUES statements, with or without an explicit column list, and any number of tuples per statement.
Are values escaped for HTML?
Yes. Angle brackets, ampersands and quotes are converted to entities, so a value can never break out of its cell.
What happens without a column list?
The columns are named col1, col2 and so on, in tuple order, so the table still lines up.
Can I style the table myself?
Yes. The table markup carries no classes or inline styles, so your own stylesheet applies. The full page option adds a small style block only.