Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The most reliable browser-side method is to render the table with html2canvas, receive a canvas, and download that canvas as a PNG. Select the table (or a wrapper), set a pixel-density scale, then export with toBlob() or toDataURL(). This works without a server, but it reconstructs the image from the DOM rather than taking a literal browser screenshot, so some CSS and cross-origin content need special handling.

What you need before you start

  • A modern evergreen browser with JavaScript enabled.
  • A table with a stable selector such as id="sales-table".
  • The html2canvas library, installed with npm install @html2canvas/html2canvas or loaded from the documented CDN build.
  • A user gesture, such as a button click, if you want the browser to start a download without popup-blocking surprises.

html2canvas runs in the browser; it is not a Node.js screenshot engine. It reads the table’s DOM and computed styles, paints an approximation to a canvas, and leaves the original table untouched.

Save one HTML table as a PNG

This complete page creates a table, loads html2canvas 1.8.0 from the CDN URL shown in the implementation guidance, and downloads only the table when the button is clicked.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Save a table as PNG</title>
  <style>
    body { font-family: system-ui, sans-serif; margin: 2rem; }
    .table-wrap { max-width: 48rem; overflow-x: auto; }
    table { border-collapse: collapse; width: 100%; background: #fff; }
    th, td { border: 1px solid #cbd5e1; padding: .65rem .8rem; text-align: left; }
    th { background: #e2e8f0; }
    .screen-only { margin-top: 1rem; }
  </style>
</head>
<body>
  <div class="table-wrap" id="table-card">
    <table id="sales-table">
      <caption>Quarterly sales</caption>
      <thead>
        <tr><th>Quarter</th><th>Region</th><th>Revenue</th></tr>
      </thead>
      <tbody>
        <tr><td>Q1</td><td>North</td><td>$42,000</td></tr>
        <tr><td>Q2</td><td>North</td><td>$48,500</td></tr>
      </tbody>
    </table>
  </div>
  <button class="screen-only" id="save-table" type="button">Save as PNG</button>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas-next/1.8.0/html2canvas.min.js"></script>
  <script>
    document.querySelector('#save-table').addEventListener('click', async () => {
      const table = document.querySelector('#sales-table');
      if (!table) return;
      const canvas = await html2canvas(table, {
        scale: window.devicePixelRatio,
        backgroundColor: '#ffffff'
      });
      canvas.toBlob((blob) => {
        if (!blob) throw new Error('Could not create PNG data');
        const link = document.createElement('a');
        const url = URL.createObjectURL(blob);
        link.download = 'sales-table.png';
        link.href = url;
        link.click();
        URL.revokeObjectURL(url);
      }, 'image/png');
    });
  </script>
</body>
</html>

How the code works

  1. document.querySelector('#sales-table') limits the capture to the table, rather than the whole page.
  2. scale: window.devicePixelRatio creates more canvas pixels on high-density displays, which generally keeps text sharper. It also increases memory use.
  3. backgroundColor: '#ffffff' gives the PNG an opaque white background. Omit it or set it to null when you deliberately need transparency and your styles support it.
  4. toBlob() avoids placing a large base64 string in memory. The object URL is revoked after the download is started.

The shorter data-URL form also works:

const link = document.createElement('a');
link.download = 'sales-table.png';
link.href = canvas.toDataURL('image/png');
link.click();

Choose the capture boundary deliberately

Capture the table element

Pass the <table> when you want just its caption, rows, borders and table styles. This is the cleanest result for a downloadable report.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Capture a wrapper

Pass a containing element such as #table-card when the table needs a title, logo, padding or a colored background. The wrapper’s dimensions become the image dimensions. If the wrapper has horizontal scrolling, make sure the content is laid out at the width you intend to export before calling html2canvas.

Capture a precise rectangle

html2canvas supports the documented x, y, width and height options. These coordinates are useful when a larger wrapper contains a small region you need to crop, but they are measured in the rendered document’s coordinate system. For most tables, selecting the exact element is less error-prone than maintaining hard-coded coordinates.

Exclude controls from the image

Put data-html2canvas-ignore on buttons, download links or other controls that should remain visible on the page but not in the output. You can also provide the documented ignoreElements predicate for a rule-based exclusion.

const canvas = await html2canvas(document.querySelector('#table-card'), {
  scale: window.devicePixelRatio,
  ignoreElements: (element) => element.matches('.screen-only')
});

Improve readability and visual consistency

Wait for the table to be ready

Call html2canvas after rows have been inserted and after fonts or images needed by the table have loaded. In an application that fetches data, await the fetch and render cycle first; otherwise the capture can contain an empty body or an earlier state. A button click naturally provides a useful wait point, but it does not wait for your own asynchronous data automatically.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a predictable background

Set the table or wrapper background explicitly. Transparent cells over a page background can look different when the PNG is opened elsewhere. A white background is usually safest for reports and spreadsheets.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Control width and wrapping

Long headings wrap according to the element’s current width. Set a deliberate width, column widths or white-space policy before capture. For a wide table, temporarily remove a responsive overflow rule or capture a wrapper whose width equals the full report width; otherwise you may export only the visible, narrow layout.

Use a larger scale only when needed

Device-pixel-ratio scaling improves legibility on dense screens, but a very large table at a high scale can consume substantial memory and produce a canvas too large for the browser. If the operation fails on large reports, reduce the scale, split the table into sections, or export a server-side image or PDF instead.

What html2canvas can and cannot reproduce

The output is a DOM reconstruction, not a pixel-for-pixel browser screenshot. The documentation explicitly cautions that the result may not be 100% accurate to the real representation because it is built from information available in the page. CSS that the library does not support can differ in the PNG, even though the table looks correct on screen.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Cross-origin images

Images hosted on another origin can be skipped or taint the canvas. Set useCORS: true only when the image server sends suitable CORS headers:

const canvas = await html2canvas(table, {
  useCORS: true,
  scale: window.devicePixelRatio
});

If the server does not send those headers, use a same-origin proxy that fetches the image and serves it from your origin. Do not expect useCORS to bypass browser content-policy restrictions; html2canvas cannot circumvent them.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Cross-origin iframes

A table inside an iframe on another origin cannot be rendered by reading that iframe’s document. Browser security prevents the parent page from accessing it. Capture the table from a page served by the same origin, ask the embedded application to provide an export, or use a remote browser screenshot service that can navigate to the page itself.

Fonts, SVG and advanced effects

Make sure web fonts are loaded before capture. Effects or CSS features that html2canvas does not implement may be approximated or omitted. Test the exact browsers and styles your users rely on instead of assuming that a visually complex dashboard will match perfectly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Download formats and data handling

PNG is the practical default for tables because it preserves sharp text and does not introduce lossy compression. The canvas API can also create a JPEG data URL or blob when a smaller photographic-style image matters, but JPEG artifacts are often noticeable around small type and grid lines. Keep the original HTML table available for searching, copying and assistive technology; the image is a visual export, not a replacement for table semantics.

Use a Blob for larger exports

The toBlob() pattern in the complete example keeps binary data out of a long data URL. You can upload that blob with fetch and FormData or save it with the File System Access API where supported. Those APIs require their own permissions and are separate from html2canvas.

Troubleshoot common failures

Symptom Likely cause Fix
The download is blank The selected element has no rendered size, the rows have not arrived, or a parent is hidden. Check getBoundingClientRect(), wait for data rendering, and capture a visible element after layout.
Images disappear The image is cross-origin without usable CORS headers. Serve it with appropriate CORS headers, set useCORS: true, or proxy it through your origin.
The table is cropped A scrolling wrapper or fixed coordinate range limits the rendered area. Capture the table or a full-width wrapper, remove the temporary overflow constraint, and avoid undersized width/height options.
Text looks soft The canvas was created at CSS-pixel resolution. Use scale: window.devicePixelRatio; lower the scale again if memory becomes a problem.
Buttons appear in the PNG Controls are descendants of the captured wrapper. Add data-html2canvas-ignore or filter them with ignoreElements.
Styles do not match the page Unsupported CSS or a different responsive breakpoint is being rendered. Use export-specific CSS, set the intended width, simplify unsupported effects, and compare output in the browsers you support.
An iframe’s table is missing It is cross-origin and inaccessible to the parent document. Capture from the iframe’s own origin or use a navigation-based screenshot service.
The browser reports a canvas security error A cross-origin resource tainted the canvas. Correct the resource’s CORS policy or replace it with a same-origin/proxied copy.

When a remote screenshot is a better fit

Use html2canvas when the export happens in the user’s browser, the table is already in your DOM, and you need a quick client-side PNG. A remote browser is more convenient for scheduled jobs, pages you do not control, cross-origin frames, or repeatable captures from a backend. It can also provide a PDF or image without asking every user to run JavaScript locally.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. One GET request can return a PNG, JPEG, WebP or PDF; its element-capture option can target a table by CSS selector. The service can load lazy images, set a viewport or device preset, use retina scale, apply custom CSS or JavaScript, click an element, wait for a selector, delay or network idle, hide selectors, block ads, trackers, requests or resource types, and set headers, cookies, user agent, Authorization, timezone or geolocation. Caching with a chosen TTL, signed links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API and an OpenAPI specification are also available. Parameter names used by other screenshot APIs work as well, which can simplify a migration.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

cURL

See the ScreenshotNeo API documentation for selector and rendering options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
require('fs').writeFileSync('shot.webp', Buffer.from(await res.arrayBuffer()));

Before capture, ScreenshotNeo accepts cookie and consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed. Every response reports the result in X-Page-Verdict and X-Billed headers. Its MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.

Plan Included shots Price
Free 1,000 per month $0, no card
Starter 3,000 $5
Growth 15,000 $15
Pro 60,000 $39
Scale 250,000 $99
Business 1,000,000 $249

Every feature is included on every plan, and yearly billing gives two months free. Create a free ScreenshotNeo account to start with 1,000 screenshots each month without a card.

FAQ

Will the exported PNG remain searchable?

No. A PNG contains pixels only. Keep the HTML table or provide a separate CSV/JSON export when readers need to search, copy or process values.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I preserve a table’s accessibility information in the image?

Not inside the bitmap itself. Retain the original semantic table in the page, add meaningful alternative text for the image, and avoid making the image the sole way to access the data.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

What should I test before enabling downloads for everyone?

Test long labels, empty cells, large row counts, responsive widths, web fonts, images from other origins, dark and light themes, and the browsers your audience uses. Compare the PNG with the rendered table at the same data state.

Frequently Asked Questions

Will the exported PNG remain searchable?

No. A PNG contains pixels only. Keep the HTML table or provide a separate CSV/JSON export when readers need to search, copy or process values.

Can I preserve a table’s accessibility information in the image?

Not inside the bitmap itself. Retain the original semantic table in the page, add meaningful alternative text for the image, and avoid making the image the sole way to access the data.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What should I test before enabling downloads for everyone?

Test long labels, empty cells, large row counts, responsive widths, web fonts, images from other origins, dark and light themes, and the browsers your audience uses. Compare the PNG with the rendered table at the same data state.

The Bottom Line

For a client-side export, select the table with html2canvas, render at an appropriate scale, and download the resulting canvas as a PNG. Use a remote capture service when browser security, automation or repeatable server-side jobs make local DOM rendering impractical.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.