· 4 min read
Convert an HTML Table Into a CSV File
Heshan Fernando
Co-founder & COO
You’ve right-clicked “View Page Source” on a webpage, found the <table> markup for the data you actually want, and copied it out — a pricing table, a schedule, a list of specs. Now you’re staring at raw <tr> and <td> tags and you just want the same data as a CSV you can open in a spreadsheet. Selecting and copying the rendered table in the browser sometimes works, but it often drags in extra formatting, merges cells wrong, or just doesn’t paste cleanly depending on the site.
Writing a scraper script for one table is disproportionate effort, and manually retyping the data defeats the purpose of having found it in machine-readable form in the first place.
What converting an HTML table to CSV actually involves
An HTML table is a nested structure of <table>, <tr> (rows), and <td> or <th> (cells) elements, with formatting tags like <b> or <span> often mixed into the cell content. Converting to CSV means walking that structure the way a browser renders it, extracting the visible text from each cell, and writing it out as comma-separated rows — stripping the HTML tags but keeping the actual data intact.
Cells that span multiple rows or columns (rowspan/colspan) are the trickiest part. CSV has no concept of a merged cell, so a converter has to decide how to represent that — usually by repeating the value across the cells it visually spans — or you lose alignment between headers and data.
Why people get stuck here
- Copy-pasting from the browser is unreliable. Selecting a rendered table and pasting into a spreadsheet sometimes works perfectly and sometimes mangles the structure, depending on the site’s CSS.
- Nested formatting tags. Bold, links, and spans inside table cells can get carried over as unwanted extra characters if a converter doesn’t strip them cleanly.
- Merged cells.
rowspanandcolspanattributes don’t have a CSV equivalent, and naive converters often misalign columns when they appear. - No easy way to grab just the markup. Viewing page source and finding the right
<table>block among a page’s full HTML is tedious for a one-off conversion.
What a good HTML-table-to-CSV converter looks like
Clean text extraction
Only the visible cell content should make it into the CSV — links, bold tags, and other inline formatting should be stripped without leaving stray characters behind.
Sensible handling of merged cells
Even an imperfect but predictable approach to rowspan/colspan beats a converter that silently drops data or shifts every column after the merge.
A preview before download
Seeing the parsed rows as an actual table lets you catch a misalignment from a merged cell before you’ve already handed the CSV to someone else.
Common mistakes to avoid
- Copy-pasting a rendered table directly into a spreadsheet app and assuming the structure came through correctly without checking a few rows.
- Grabbing the wrong
<table>block from a page with multiple tables in its source. - Not accounting for
rowspan/colspancells, which can silently shift every column to the right in a naive conversion. - Leaving stray HTML entities (
&, ) unconverted in the output, which show up as garbled text in the final CSV.
How to do it with HTML Table to CSV
Online Tool Store’s HTML Table to CSV converts the markup locally in your browser.
- Copy the
<table>...</table>HTML markup from the page source. - Paste it into the tool.
- Review the parsed rows in the preview.
- Copy or download the resulting CSV.
Because the conversion happens locally, it’s a fast way to pull structured data out of a page’s markup without writing a scraper for a task you’ll only do once.
Frequently asked questions
Do I need the whole page’s HTML, or just the table?
Just the <table> element and everything inside it — copying the whole page’s source works too, but isolating the table markup first makes the preview easier to check.
What happens to links and images inside table cells?
Text extraction keeps the visible text but drops the underlying link URL or image — if you need the link itself, you’ll want to check the raw HTML separately for that cell.
Can this handle tables with merged cells (rowspan/colspan)?
It handles them by mapping the merged value across the cells it visually spans, but merged cells are the one case worth checking in the preview before trusting the output, since CSV has no native concept of a merged cell.
Final thought
If the data you need is already sitting in a page’s HTML as a table, converting it directly beats retyping or fighting with copy-paste formatting — just double-check any merged cells in the preview before you trust the result.