How to Extract Stubborn HTML Tables in Chrome
In this article
This guide shows you how to capture, copy, and extract HTML tables from Chrome—even the ones that resist normal copy-paste. You'll learn built-in methods, a quick JavaScript trick for stubborn tables, and how to export clean data to Excel or CSV. No extra software needed, just Chrome and a few minutes.
What You'll Need
- Google Chrome (any recent version)
- The webpage containing the table you want to extract
- A text editor (like Notepad) or spreadsheet app (like Excel or Google Sheets)
Step-by-Step
- Open the page and locate the table. Navigate to the site with the table. Scroll so the table is visible on screen.
- Try the simple copy method first. Click and drag your mouse to select the entire table (or press Ctrl+A to select all, then narrow it down). Right-click and choose Copy, or press Ctrl+C. Paste into a spreadsheet or text editor. If the data appears cleanly, you're done. If not, move to the next step.
- Use Chrome's built-in 'Copy as HTML' feature. Right-click the selected table and choose Copy > Copy as HTML (or simply Copy if that's the only option). This copies the underlying HTML code, which you can paste into a text editor to inspect or convert later.
- Open Developer Tools for stubborn tables. Right-click anywhere on the table and select Inspect. The DevTools panel opens with the table's HTML highlighted in the Elements tab.
- Copy the table's outer HTML. In DevTools, right-click the highlighted
<table>element in the Elements panel. Choose Copy > Copy outerHTML. This captures the entire table markup, including all rows and cells. - Paste the HTML into a text editor. Open Notepad (or any text editor) and paste (Ctrl+V). Save the file with a
.htmlextension, e.g.,table.html. - Open the saved HTML in Chrome. Double-click the file or drag it into a Chrome tab. The table will render as a plain webpage.
- Now copy the rendered table normally. Select the table on the rendered page, right-click, and choose Copy. Paste into Excel or Google Sheets. This often works when the original page had scripts or dynamic content that interfered.
- For truly stubborn tables, use a JavaScript one-liner. With the original page open, press F12 to open DevTools. Go to the Console tab. Type the following and press Enter:
copy(document.querySelector('table').outerHTML);
This copies the first table's HTML to your clipboard. If there are multiple tables, use a more specific selector likedocument.querySelectorAll('table')[2](replace 2 with the index number). - Paste and convert the copied HTML. Paste the copied HTML into a text editor, save as
.html, open in Chrome, then copy and paste into your spreadsheet as in steps 7-8. - Export to CSV if you need plain text. Once the table is in Excel or Google Sheets, use File > Save As (Excel) or File > Download > Comma-separated values (Google Sheets) to get a CSV file.
Common Mistakes
- Selecting only visible cells: Some tables have hidden columns or rows. If you select manually, you might miss them. Use the HTML copy method to get everything.
- Copying from a dynamic page: If the table loads via JavaScript after the page loads, copying the initial HTML might give you empty data. Wait for the table to fully render, or use the DevTools method after it's loaded.
- Using the wrong selector in the console: If you use
document.querySelector('table')and there are multiple tables, you'll only get the first one. Always check the number of tables or use a more specific selector. - Pasting HTML directly into Excel: Excel may not parse HTML correctly. Always paste into a text editor first, then open in a browser to convert to plain text.
- Forgetting to save as .html: If you save the copied HTML as .txt, Chrome will show it as plain text, not a rendered table. Use the .html extension.
Tips
- Use the 'Copy as HTML' option in DevTools: Right-click the
<table>element and choose Copy > Copy outerHTML for the most reliable capture. - For multiple tables: In the console, you can run
document.querySelectorAll('table').lengthto see how many tables exist, then adjust the index in your copy command. - Clean up extra formatting: After pasting into a spreadsheet, use the 'Text to Columns' feature (Excel) or 'Split text to columns' (Google Sheets) if data lands in one column.
- Use a bookmarklet for repeated needs: Create a bookmark with the JavaScript code as the URL. Click it on any page to copy the table HTML instantly.
- Check for pagination: If the table spans multiple pages, you'll need to repeat the process for each page or look for a 'Show all' option.
Troubleshooting
- Copy command returns 'undefined' in console: This is normal—the copy function doesn't output anything. Check your clipboard by pasting into a text editor.
- The table is empty when pasted: The table might be loaded via AJAX. Wait for the page to fully load, or try refreshing and then copying. If it's still empty, the data might be in a different element (like a div), not a table.
- Pasting into Excel shows garbled text: This happens when you paste HTML directly. Always paste into a text editor first, then open the .html file in Chrome and copy the rendered table.
- Only part of the table is copied: If you used manual selection, you might have missed rows. Use the DevTools method to copy the entire table element.
- The table isn't in a
<table>tag: Some sites use divs styled as tables. In that case, use the DevTools to copy the container element (like a<div>with a class like 'table'). You may need to adjust the selector accordingly.
Frequently Asked Questions
Can I extract a table without using Developer Tools?
Yes, try the simple copy method first. If that fails, the DevTools method is the most reliable, but you can also try right-clicking and selecting 'Copy as HTML' from the context menu.
How do I copy a table from a page that requires scrolling?
Scroll to the bottom of the table to load all rows, then use the DevTools method—it copies the entire table regardless of what's visible.
Why does the copied table lose its formatting?
When you paste into a spreadsheet, formatting like colors and borders is usually lost. If you need to keep the exact look, save the HTML and open it in a browser, then print to PDF or use a browser extension to capture a screenshot.
Can I extract a table from a PDF opened in Chrome?
Yes, if the PDF has a real table (not an image), you can use the same DevTools method. Right-click on the table, inspect, and copy the outerHTML. If it's an image, you'll need OCR software.
Is there a way to automatically export all tables on a page?
You can run a JavaScript snippet in the console to loop through all tables and copy each one, but it's easier to use a browser extension like 'Table Capture' that does this with one click.
What if the table is inside an iframe?
You'll need to inspect the iframe first. Right-click inside the iframe and select 'Inspect', then find the table within the iframe's DOM. The copy method works the same.