SQL to HTML Table Converter
CV-67Paste INSERT statements and get an HTML table for each one, with the column names as headings. Other statements are skipped.
Runs in your browser. Nothing is uploaded.
SQL INSERT statements
HTML
How to use it
- Paste your INSERT ... VALUES statements into the input box.
- Choose how NULL is shown and whether to turn on backslash escapes for MySQL dumps.
- Pick the indent and whether to add the table name as a caption.
- Copy the HTML or download it as a .html file.
What is read from the SQL
The tool reads INSERT INTO table (columns) VALUES (...), (...); statements, including several rows in one statement. Table and column names can be plain, [bracketed], `backticked` or "double-quoted". Strings lose their quotes and a doubled quote becomes one. Numbers are copied exactly as written, so 9007199254740993 is not rounded. NULL is shown as an empty cell or as the word NULL. Expressions such as NOW() are shown as their source text and are not evaluated.
What is skipped or rejected
CREATE TABLE, SELECT and other statements are skipped, as are -- and /* */ comments. INSERT ... SELECT and INSERT ... SET are rejected with a message, because they hold no values to show. Dollar-quoted strings and E'' strings are not read. Backslash escapes such as \n are decoded only if you turn the MySQL option on, since in most databases a backslash in a string is a plain character.
The table markup
Each INSERT statement becomes its own table with a caption holding the table name, a thead of column names and a tbody of rows. If there is no column list, the headings are column_1, column_2 and so on. A row whose number of values differs from the column list is an error that names the row. All text is HTML-escaped, and line breaks inside a value become br tags. No CSS is added.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
No INSERT INTO ... VALUES statements found. Paste statements such as INSERT INTO users (id, name) VALUES (1, 'Ada'); | The input has no INSERT ... VALUES statement. | Paste at least one INSERT statement with a VALUES list. |
A quoted string is never closed at line 1, column 27 | A string literal has an opening quote with no matching closing quote. | Add the closing quote, or double any quote inside the text. |
Row 2 of the INSERT into t has 1 value but the column list has 2 | A row has a different number of values than the column list. | Add or remove a value so every row matches the columns. |
Only INSERT ... VALUES is read; the INSERT into t uses SELECT | The statement takes its rows from a query, not from a VALUES list. | Paste an INSERT with a VALUES list. |
Questions people ask
How do I convert SQL INSERT statements to HTML?
Paste the statements. Each INSERT becomes an HTML table with the column names as headings. Copy the result or download it as a .html file.
Does it run my SQL or connect to a database?
No. It only reads the text of INSERT statements in your browser. Nothing is executed and no database is contacted. Copy the result or download it with the buttons above the output.
Are big numbers and decimals changed?
No. Numbers are copied exactly as you wrote them, so 12345678901234567890 and 19.90 come out the same. The tool never turns them into JavaScript numbers.
Can it read a mysqldump file?
It reads the INSERT statements in it and skips the rest. Turn on Backslash escapes (MySQL), because mysqldump writes quotes and newlines as \' and \n in strings.
What happens to NULL values?
They show as an empty cell by default, or as the word NULL if you choose that. A real empty string also shows as an empty cell, so pick NULL if you need to tell them apart.
About this tool
Reads INSERT INTO table (columns) VALUES (...), (...); statements and writes one HTML table for each statement, with the columns as headings and the table name as a caption (option). Other statements, such as CREATE TABLE or SELECT, and -- and /* */ comments are skipped. Table and column names can be plain, [bracketed], `backticked` or "double-quoted". Strings lose their quotes and doubled quotes become one; an N prefix is accepted. Numbers are copied exactly as written, so 9007199254740993 is not rounded. NULL is shown as empty or as the word NULL. Other expressions, such as NOW() or CAST(1 AS int), are shown as their source text and are not evaluated. Backslash escapes (\n, \') are read only if you turn that option on. Without a column list the headings are column_1, column_2 and so on. A row whose value count differs from the column list is an error. All text is HTML-escaped. Not read: INSERT ... SELECT, INSERT ... SET, dollar-quoted ($$) strings and E'' strings.