HTML Table Generator
Turn tabular text into reusable HTML table code
HTML Table Generator — what it does
Paste tabular text, choose whether the first row is a header, pick a table style and get clean HTML table markup with a live preview. The output uses proper table, thead and tbody structure — the semantics screen readers rely on — rather than a stack of divs pretending to be a grid.
Worked example
A four-line product list pasted as comma-separated text, with First row is header ticked and the Plain style selected.
Table data — CSV
Item,Qty,Unit price Desk lamp,2,"1,250" USB-C cable <2 m>,10,180 "Chair, mesh",1,4990
Output — HTML (one line)
<table style="border-collapse:collapse;width:100%"><thead><tr><th>Item</th><th>Qty</th><th>Unit price</th></tr></thead><tbody><tr><td>Desk lamp</td><td>2</td><td>1,250</td></tr><tr><td>USB-C cable <2 m></td><td>10</td><td>180</td></tr><tr><td>Chair, mesh</td><td>1</td><td>4990</td></tr></tbody></table>
Quoted cells keep their embedded comma and lose the quotes, < and > are escaped, and the header row sits in thead with the data rows in tbody, all on one line. The Bordered style adds a style attribute with border, padding and alignment to every cell.
When this tool helps
- Adding a specification or pricing table to a page without hand-typing table markup.
- Converting spreadsheet data into HTML for a CMS that accepts raw markup.
- Building a quick comparison table for documentation or a blog post.
How to use it
- Paste your rows and columns into the data box.
- Tick whether the first row is a header.
- Choose a table style.
- Generate, preview, then copy or download the HTML.
Accuracy, limits, and good practice
- Marking the first row as a header emits th elements, which is what lets screen readers announce each cell's column.
- Keep tables for tabular data. Using them for page layout is a long-abandoned practice that hurts accessibility and responsiveness.
- Wide tables need a scrollable container on mobile; otherwise they force the whole page to scroll sideways.
Frequently asked questions
Should I add a caption?
Yes when the table needs a title — a caption element is announced by assistive technology and beats a heading floating above it.
How do I make it responsive?
Wrap it in a container with horizontal overflow scrolling, so the table scrolls inside the page rather than stretching it.
Can I merge cells?
Colspan and rowspan are not generated here; add those attributes by hand to the generated markup.
How does it decide between commas and tabs?
If the pasted text contains a tab anywhere, every line is split on tabs (which is what a copy from Excel or Google Sheets gives you); otherwise it is parsed as CSV with quote support. In tab mode quotes are not special, so a cell copied as "Chair, mesh" keeps its quotation marks.
What does the Download button give me?
A file named table.html containing a minimal document (doctype, UTF-8 meta and the title "Table") followed by the same table markup shown on the page. The button stays disabled until you have generated a table at least once.
Related tools on this site
- Line Prefix & Suffix — Add numbering, prefixes, or suffixes to every line
- Text Base64 Encoder — Encode or decode UTF-8 text with Base64
- YAML to JSON — Parse YAML and export formatted JSON
Further reading: Cleaning Up Text You Pasted From Somewhere Else
Everything above runs inside this page. HTML Table Generator needs no account, no upload, and no server round trip — close the tab and nothing is left behind.
HTML 表格生成器能做什麼
貼上表格式文字,選擇第一列是否為標題、挑一個表格樣式,即可得到附即時預覽的乾淨 HTML 表格標記。輸出使用正規的 table、thead 與 tbody 結構——螢幕閱讀器所依賴的語意——而不是一堆假裝成網格的 div。
實際範例
四行以逗號分隔的產品清單,勾選第一列為標題並選擇 Plain 樣式。
表格資料:CSV
Item,Qty,Unit price Desk lamp,2,"1,250" USB-C cable <2 m>,10,180 "Chair, mesh",1,4990
產生的 HTML(單獨一行)
<table style="border-collapse:collapse;width:100%"><thead><tr><th>Item</th><th>Qty</th><th>Unit price</th></tr></thead><tbody><tr><td>Desk lamp</td><td>2</td><td>1,250</td></tr><tr><td>USB-C cable <2 m></td><td>10</td><td>180</td></tr><tr><td>Chair, mesh</td><td>1</td><td>4990</td></tr></tbody></table>
帶引號的儲存格保留內含的逗號並去掉引號,< 與 > 會被跳脫,標題列放在 thead、資料列放在 tbody,全部寫成一行。Bordered 樣式會在每個儲存格加上含框線、內距與對齊的 style 屬性。
什麼時候用得上
- 為頁面加入規格表或價目表,不必手打表格標記。
- 把試算表資料轉成 HTML,供接受原始標記的 CMS 使用。
- 為文件或部落格文章快速做一張比較表。
使用步驟
- 把資料列與欄貼進資料框。
- 勾選第一列是否為標題。
- 選擇表格樣式。
- 產生、預覽,再複製或下載 HTML。
精確度、限制與實務建議
- 把第一列標為標題會輸出 th 元素,螢幕閱讀器才能為每個儲存格報出所屬欄位。
- 表格請用於表格資料。拿來做頁面版面早已被淘汰,且會傷害無障礙與響應式表現。
- 寬表在行動裝置上需要可捲動的外層容器,否則整頁都會被迫左右捲動。
常見問題
需要加標題說明嗎?
表格需要標題時建議加 caption 元素,輔助科技會朗讀它,效果優於浮在上方的一般標題。
怎麼做成響應式?
用可水平捲動的容器包住,讓表格在頁面內捲動,而不是把整頁撐開。
可以合併儲存格嗎?
此處不會產生 colspan 與 rowspan,請在產生的標記上手動加入。
工具怎麼決定以逗號還是 Tab 分欄?
只要貼上的文字裡有任何一個 Tab,每行就以 Tab 切開(從 Excel 或 Google 試算表複製的就是這種);否則當作 CSV 解析並支援引號。Tab 模式下引號沒有特殊意義,所以複製來的 "Chair, mesh" 會連引號一起保留。
下載按鈕會給我什麼?
一個名為 table.html 的檔案,內含最精簡的文件骨架(doctype、UTF-8 meta 與標題「Table」),後面接著與畫面上相同的表格標記。至少產生過一次表格,按鈕才會啟用。
本站相關工具
- 每行前後綴工具 — 為每一行加入編號、前綴或後綴
- 文字 Base64 編解碼 — 將 UTF-8 文字進行 Base64 編碼或解碼
- YAML 轉 JSON — 解析 YAML 並輸出格式化 JSON
延伸閱讀: 清理從別處貼上的文字
以上步驟全部在這個頁面內完成,HTML 表格生成器 不需要註冊、不上傳檔案、也不經過伺服器,關閉分頁後不會留下任何資料。