Anyone who does B2B lead research, procurement analysis, SaaS benchmarking, or operations work knows the quiet frustration of moving tabular web data into a spreadsheet.

Highlight an HTML table or a trade-show exhibitor directory, hit Ctrl+C, paste into Excel or Google Sheets, and everything falls apart:

  • Merged colspan / rowspan headers shift half the columns to the left.
  • Modern SaaS directories and catalog grids do not even use <table> elements—they render CSS Grid or Flexbox cards.
  • Price cells mix formats like $1,299.00 / mo, €499,50 / yr, and hidden non-breaking spaces (\u00A0), breaking SUM() and sorting.
  • Plain UTF-8 CSV exports open with garbled accented characters (€, £, ü, é) in desktop Microsoft Excel on Windows.
  • Meanwhile, many legacy Manifest V2 scraper extensions either stopped working or demand blanket <all_urls> host permissions the moment you install them.

We built TableCraft AI (live on Chrome Web Store and Microsoft Edge Add-ons) as a zero-dependency Manifest V3 Side Panel extension that extracts, cleans, and exports both standard HTML tables and repeating card directories completely locally in the browser.

Here are the engineering problems we had to solve inside table-engine.js.

1. Dual-Environment Zero-Dependency Architecture

Chrome Manifest V3 chrome.scripting.executeScript({ target, func }) serializes and injects a self-contained function into the active tab. Pulling in heavy DOM libraries or bundler runtimes breaks injection cleanliness and bloats review overhead.

Instead, we structured extension/table-engine.js (~1,377 lines of pure ESM, zero npm runtime dependencies) so the exact same extractDatasetsInPage(targetDoc) function runs in two environments:

  1. In-Browser MV3 Injection: Executes directly against the live document when the user clicks Scan in the Side Panel.
  2. Offline Node.js Test Harness: Paired with a lightweight built-in HTML tokenizer and MiniNode CSS selector engine (matchesSingleChain, supporting descendant/child combinators, #id, .class, and [attr^=/*=/$=] selectors), letting npm test run 18 deterministic end-to-end tests against real messy HTML fixtures with zero Puppeteer overhead.

2. Normalizing colspan/rowspan Tables vs. Repeating Card Directories

Real webpages split into two completely different DOM patterns, so the extractor runs two complementary passes:

Pass A: True HTML <table> Grid Normalization

  • Skips outer layout wrapper tables that merely wrap an inner data table (hasRichNestedTable).
  • Walks <thead>, <tbody>, and <tfoot> rows while expanding colspan and rowspan cells into a rectangular matrix.
  • Flattens multi-row headers into readable compound column titles (Parent - Child) and trims phantom empty columns caused by trailing layout spans.
  • Preserves hidden links inside generic anchors (Visit, Website, mailto:) so contact URLs and emails are not lost when inner text only says "Visit site".

Pass B: Repeating Card & Directory Clustering (>= 3 Sibling Nodes)

Most SaaS directories, pricing grids, and exhibitor catalogs use repeating <div>, <li>, or <article> cards rather than <table>.

To detect them without site-specific CSS rules, getCardSignature() strips transient state and utility-layout tokens before grouping sibling nodes:

function getCardSignature(el) { const tag = (el.tagName || '').toUpperCase(); const rawCls = cleanText(el.getAttribute ? el.getAttribute('class') || '' : el.className || ''); const tokens = rawCls .split(/\s+/) .filter(Boolean) .filter( (t) => !/^(active|selected|first|last|odd|even|featured|highlight|sponsored|open|closed|is-|has-|js-|col-|w-|p-|m-|px-|py-|mt-|mb-)/i.test( t ) ) .slice(0, 3) .sort(); return `${tag}|${tokens.join('.')}`; } 

Once a parent container yields 3 or more structurally matching sibling cards, inferFieldNameFromElement() derives clean column names in strict priority order: data-field / data-col attributes → short aria-label → heading tags (H1–H6 → Name) → semantic class tokens (email, website, price, booth, category, location, rating) → fallback field index.

3. Deterministic 6-Step Local Cleaning Pipeline (Including European Decimals)

Extraction is only half the job. Before exporting, cleanDataset() runs a 6-step deterministic pipeline entirely in local memory:

  1. Column Projection & Whitespace Collapse: Strips \u00A0, hidden tabs, and erratic newlines; honors user inline header renames and column toggles.
  2. Empty Row & Empty Column Trimming: Drops blank spacer rows and ghost columns while recording exact removal counts.
  3. Multi-Region Currency & Billing-Period Splitting: When at least 40% of non-empty cells in a column parse as prices, the cleaner automatically splits it into <Col> (Numeric), <Col> (Currency), and <Col> (Period) columns—distinguishing European decimal commas (1.299,50, 49,50) from US thousands separators (1,299.00):
// Distinguish European decimal comma vs thousands comma if (/^\d{1,3}(\.\d{3})+,\d{1,2}$/.test(numStr)) { numStr = numStr.replace(/\./g, '').replace(',', '.'); } else if (/^\d+,\d{2}$/.test(numStr) && !numStr.includes('.')) { numStr = numStr.replace(',', '.'); } else { numStr = numStr.replace(/,/g, ''); } 
  1. Embedded Contact Extraction: Pulls buried emails and https:// URLs out of cluttered notes columns into dedicated Extracted Email / Extracted URL columns when none exist yet.
  2. Cross-Page Append & Deduplication: Uses the ASCII Unit Separator (\u241F) to build collision-safe row signatures across paginated captures (mergeDatasets()), aligning newly discovered columns on page 2+ automatically.
  3. Optional On-Demand AI Schema Normalization: When unstructured directory cells still pack 3 attributes into one sentence (e.g., "Acme Corp · Berlin, DE · Series B"), users can explicitly click Run AI Column Normalization to split them via a stateless Cloudflare Worker—with automatic fallback to local deterministic cleaning if offline.

4. Zero-Garble Exporters (UTF-8 BOM CSV, TSV, JSON, GFM Markdown)

Microsoft Excel on Windows defaults to legacy ANSI code pages when opening a raw UTF-8 CSV without a Byte Order Mark, mangling €, £, and European diacritics.

Our RFC-4180 exporter prepends \uFEFF by default and normalizes CRLF line endings:

export function exportToCsv(headers, rows, { bom = true } = {}) { const esc = (val) => `"${String(val ?? '').replace(/"/g, '""')}"`; const headerLine = headers.map(esc).join(','); const dataLines = rows.map((r) => headers.map((_, i) => esc(r[i] ?? '')).join(',')); const body = [headerLine, ...dataLines].join('\r\n'); return (bom ? '\uFEFF' : '') + body; } 

Alongside UTF-8 BOM CSV, the Side Panel provides 1-Click Copy TSV (paste directly into Google Sheets or Excel with zero import wizard), Structured JSON (auto-deduplicating colliding column keys), and GitHub-Flavored Markdown tables for docs and Notion.

5. Privacy-First Manifest V3 Permissions

Instead of declaring mandatory <all_urls> host permissions at install time—which slows store review and violates user trust—TableCraft AI uses:

  • activeTab + sidePanel + scripting + storage at install time (zero background content scripts running passively on every page you visit).
  • On-demand optional_host_permissions requested strictly inside the user's explicit click gesture when capturing across tabs or multi-page pagination.
  • 100% local deterministic extraction, cleaning, and CSV/TSV/JSON/Markdown export with zero webpage content leaving the browser unless the user manually triggers AI normalization.

Try TableCraft AI Free

Free forever for up to 100 rows per table/directory with zero account required, plus 5 free AI schema-cleaning runs. If you have nasty real-world HTML tables or directory layouts that usually break scrapers, drop an example pattern in the comments—we love adding tricky fixtures to our offline test suite.