HTML Table to CSV
Extract an HTML table and download it as a CSV file
HTML Table to CSV — what it does
Paste HTML source, pick which table on the page you want by index, and extract it to CSV. Copying a web table into a spreadsheet usually drags in styling, merged layout and hidden markup; going through the source and extracting the cells gives you clean data instead.
Worked example
A page fragment with two tables, a one-row contact list and a four-row price list, with Table index set to 1 to pick the second one.
Input — HTML source, table index 1
<table> <tr><th>Contact</th><th>Email</th></tr> <tr><td>Ann Lee</td><td>ann.lee@example.com</td></tr> </table> <table> <tr><th>SKU</th><th>Product</th><th>Unit price</th><th>In stock</th></tr> <tr><td>NB-100</td><td>Notebook, A5</td><td>3.50</td><td>Yes</td></tr> <tr><td>ST-200</td><td>Stapler</td><td>8.99</td><td>No</td></tr> <tr><td>DL-300</td><td>Desk lamp</td><td>24.00</td><td>Yes</td></tr> </table>
Output — table.csv (4 row(s))
SKU,Product,Unit price,In stock NB-100,"Notebook, A5",3.50,Yes ST-200,Stapler,8.99,No DL-300,Desk lamp,24.00,Yes
Notebook, A5 is quoted because it contains a comma; th and td cells are treated alike. The file starts with a UTF-8 byte-order mark.
When this tool helps
- Getting a published statistics or pricing table off a page and into a spreadsheet.
- Extracting a table from an emailed HTML report that has no attachment.
- Pulling structured data out of a page's saved source for analysis.
How to use it
- Paste the HTML source containing the table.
- Set the table index if the page has several tables.
- Extract the table.
- Download the CSV result.
Accuracy, limits, and good practice
- Index counts tables in source order, so start at the first and step through until the preview matches the table you want.
- Merged cells flatten during extraction, which can shift values; check the first few rows against the original.
- Respect the source: check a site's terms before extracting and republishing data you did not create.
Frequently asked questions
Where do I get the HTML source?
View source in the browser, or save the page and open the file — then paste the markup here.
What if the table is built by JavaScript?
You need the rendered markup, not the original source. Copy it from the browser's element inspector instead.
Do header cells become the CSV header?
Header cells appear as the first row of the CSV, which is what any spreadsheet or parser will treat as the header.
Is the table index 0-based?
Yes: 0 is the first table in the source and 1 the second, as in the example; an index past the last table gives 'Table not found.' The HTML-to-Excel tool on this site numbers tables from 1 instead, so the same table needs a different index there.
How much does the preview show?
The first 15 rows, with | between cells; the download holds every row. Cell text is trimmed, and a cell that contains a line break is quoted in the CSV rather than split.
Related tools on this site
- JSON Difference Viewer — Compare two JSON documents and list added, removed, and changed values
- CSV Column Merger — Combine selected CSV columns into a new field
- CSV Group & Aggregate — Group rows and calculate sum, average, count, min, or max
Further reading: Cleaning a CSV export before you import it anywhere · CSV, JSON, YAML, XML and Markdown Tables: When Each Fits and How to Convert
Everything above runs inside this page. HTML Table to CSV needs no account, no upload, and no server round trip — close the tab and nothing is left behind.
HTML 表格轉 CSV能做什麼
貼上 HTML 原始碼、以索引指定頁面中的第幾張表格,即可抽取成 CSV。直接把網頁表格複製進試算表,常會連樣式、合併版面與隱藏標記一起帶進去;從原始碼抽取儲存格,拿到的才是乾淨資料。
實際範例
一段含兩個表格的網頁原始碼(一列的聯絡人表與四列的價目表),Table index 設為 1 以挑第二個表格。
來源:HTML 原始碼,表格索引 1
<table> <tr><th>Contact</th><th>Email</th></tr> <tr><td>Ann Lee</td><td>ann.lee@example.com</td></tr> </table> <table> <tr><th>SKU</th><th>Product</th><th>Unit price</th><th>In stock</th></tr> <tr><td>NB-100</td><td>Notebook, A5</td><td>3.50</td><td>Yes</td></tr> <tr><td>ST-200</td><td>Stapler</td><td>8.99</td><td>No</td></tr> <tr><td>DL-300</td><td>Desk lamp</td><td>24.00</td><td>Yes</td></tr> </table>
產生的檔案:table.csv(4 row(s))
SKU,Product,Unit price,In stock NB-100,"Notebook, A5",3.50,Yes ST-200,Stapler,8.99,No DL-300,Desk lamp,24.00,Yes
Notebook, A5 因含逗號而被加上引號;th 與 td 一視同仁。檔案開頭帶 UTF-8 位元組順序記號。
什麼時候用得上
- 把網頁上公布的統計或價目表抓進試算表。
- 從沒有附件的 HTML 郵件報表中抽出表格。
- 從存下的頁面原始碼中取出結構化資料以供分析。
使用步驟
- 貼上含有表格的 HTML 原始碼。
- 若頁面有多張表格,設定表格索引。
- 執行抽取。
- 下載 CSV 結果。
精確度、限制與實務建議
- 索引依原始碼中的表格順序計算,從第一張開始逐一試,直到預覽符合你要的表格。
- 合併儲存格在抽取時會被攤平,可能造成數值位移;請比對前幾列與原始表格。
- 尊重來源:抽取並轉發非你創作的資料前,請先確認該網站的使用條款。
常見問題
HTML 原始碼從哪裡取得?
在瀏覽器中檢視原始碼,或把頁面存檔後開啟檔案,再把標記貼過來。
表格是 JavaScript 產生的怎麼辦?
你需要的是渲染後的標記而非原始碼,請改從瀏覽器的元素檢視器複製。
標題儲存格會變成 CSV 標題嗎?
標題儲存格會成為 CSV 的第一列,任何試算表或解析器都會把它當作標題。
表格索引從 0 起算嗎?
是:0 是原始碼裡第一個表格、1 是第二個(範例即是);索引超過最後一個表格會顯示 Table not found.。本站的 HTML 轉 Excel 工具則從 1 起算,同一個表格在那邊要填不同的索引。
預覽會顯示多少?
前 15 列,儲存格之間以 | 分隔;下載檔含全部列。儲存格文字會去掉前後空白,含換行的格子在 CSV 裡會以引號包住而不是被拆開。
本站相關工具
- JSON 差異檢視器 — 比較兩份 JSON 並列出新增、移除與修改內容
- CSV 欄位合併 — 將選定 CSV 欄位合併成新欄位
- CSV 分組彙總 — 依欄位分組並計算加總、平均、計數、最小或最大值
延伸閱讀: 匯入之前先把 CSV 匯出檔清乾淨 · CSV、JSON、YAML、XML 與 Markdown 表格:各自適用的場合與轉換方法
以上步驟全部在這個頁面內完成,HTML 表格轉 CSV 不需要註冊、不上傳檔案、也不經過伺服器,關閉分頁後不會留下任何資料。