Developers often ask: "How can I use Chrome DevTools to copy a table as CSV?" While it is possible to write JavaScript in the console to extract data, it's often faster and more accurate to use a dedicated tool. This guide covers both the "Hacker Way" (Console) and the "Pro Way" (Extension).
Method 1: The "Hacker Way" (Chrome Console)
If you are comfortable with JavaScript, you can extract table data directly from the Console tab.
Step 1: Open DevTools
Press F12 or Ctrl+Shift+I to open Chrome DevTools.
Step 2: Run Extraction Script
Paste this code into the Console to get a basic CSV output:
var csv = [];
var rows = document.querySelectorAll("table tr");
for (var i = 0; i < rows.length; i++) {
var row = [], cols = rows[i].querySelectorAll("td, th");
for (var j = 0; j < cols.length; j++)
row.push('"' + cols[j].innerText.replace(/"/g, '""') + '"');
csv.push(row.join(","));
}
console.log(csv.join("\n"));
Why this fails
- ⌠Merged Cells: Doesn't handle
rowspanorcolspan. - ⌠Nested Tables: Breaks if tables are inside tables.
- ⌠Pagination: Only exports the visible page.
- ⌠Encoding: Might mess up special characters (UTF-8).
Method 2: The "Pro Way" (Table to Excel Extension)
For a reliable, one-click solution that handles all edge cases (merged cells, images, links), use the Table to Excel extension.
- Install Table to Excel from the Web Store.
- Hover over any table on the page.
- Click "CSV" in the floating menu.
Why it's better
- ✅ Accurate: Preserves table structure perfectly.
- ✅ Fast: No coding required.
- ✅ Safe: Runs locally in your browser.
- ✅ Powerful: Handles CSS Grid and Div-based tables.
Method 3: copy(object) Command
Chrome has a built-in copy() function.
- Inspect the table element.
- Right-click the
<table>tag > "Store as global variable" (usually saves astemp1). - Run
copy(temp1.outerHTML)to copy the HTML. - Paste into Excel (it will paste as HTML, not CSV).
Comparison
| Feature | Chrome Console | Table to Excel |
|---|---|---|
| Ease of Use | Hard (Code) | Easy (1-Click) |
| Merged Cells | ⌠Fails | ✅ Preserved |
| Large Tables | âš ï¸ Laggy | ✅ Fast |
Stop Writing Scripts. Start Exporting.
Save hours of manual work with the professional tool.
â¬‡ï¸ Add to Chrome — Free