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

To capture a WebGL canvas you control, export its pixels with toBlob() or toDataURL() while the intended frame is still available. The default WebGL drawing buffer may be cleared after the browser composites it, so a later export can be blank or stale. If you need the capture later, you can request preserveDrawingBuffer: true when creating the context, but that option can reduce performance. If you cannot change the app, use a browser-level screenshot workflow instead.

Choose the capture method that matches your goal

What you need Use this method Important limitation
Save only the WebGL render, with access to the app code Export the canvas with toBlob() or toDataURL() while the frame is readable. Timing matters because the default drawing buffer is not guaranteed to retain its contents after compositing. Khronos WebGL Specification 1.0
Export after the rendering function has returned Consider preserveDrawingBuffer: true at context creation, or redesign capture around a synchronous read or framebuffer. Preservation may hurt performance, and context attributes cannot be changed after the first getContext() call. Chrome for Developers
Capture the visible browser tab, including browser-rendered content Use a browser screenshot feature or an extension capture API supported by the browser. This captures the visible view, not a direct export of the canvas pixels. The html2canvas FAQ names chrome.tabs.captureVisibleTab() for Chrome, Edge, and Opera. html2canvas FAQ
Recreate a page area from DOM and styles Use a DOM-reconstruction library such as html2canvas, then export its output. It builds an image from DOM information rather than taking a native browser screenshot, so the result may differ from what the browser displayed. html2canvas documentation

Export the WebGL canvas from your application

A WebGL canvas is still an HTML canvas, so canvas image-export methods can save its rendered content when the pixels are available. Call the export at a point in the render flow when the intended frame is present; do not assume it will remain readable after the browser has composited the frame.

Export a PNG with toBlob()

Call this after drawing the frame you want to save. The callback receives a PNG blob that can be downloaded or passed to other code.

function saveCanvasPng(canvas) {
  canvas.toBlob((blob) => {
    if (!blob) {
      console.error('Canvas export returned no image.');
      return;
    }

    const link = document.createElement('a');
    link.href = URL.createObjectURL(blob);
    link.download = 'webgl-capture.png';
    link.click();
    URL.revokeObjectURL(link.href);
  }, 'image/png');
}

// Call after rendering the frame you intend to capture:
renderer.render(scene, camera);
saveCanvasPng(renderer.domElement);

Replace renderer.domElement with the actual canvas element used by your app. If your rendering loop schedules another frame or clears the drawing buffer before the export reads it, move the capture call into the appropriate render step.

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.

Export as a data URL

toDataURL() returns an encoded image string. It is convenient for small captures or when an API expects a data URL; for larger images, toBlob() avoids holding the complete base64 string in memory.

const canvas = document.querySelector('canvas');
const pngDataUrl = canvas.toDataURL('image/png');

const link = document.createElement('a');
link.href = pngDataUrl;
link.download = 'webgl-capture.png';
link.click();

When to use preserveDrawingBuffer

WebGL does not guarantee that the default drawing buffer keeps its contents after compositing. With preservation disabled, later operations that use the canvas as a source can have undefined behavior. If capture must happen after the render function returns, you can request preservation when creating the context:

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.
const canvas = document.querySelector('canvas');
const gl = canvas.getContext('webgl', {
  preserveDrawingBuffer: true
});

// Initialize WebGL resources and render as usual.
// Later, while the desired frame is present:
canvas.toBlob((blob) => {
  if (!blob) return;
  // Save or process the blob.
}, 'image/png');

This must be set on the initial context creation call. If some library or framework has already called getContext() on that canvas, you cannot change the context attribute afterward; create the context with the option from the start or use a different capture strategy. The Khronos specification warns that buffer preservation can cause significant performance loss on some platforms, so use it only when the capture timing requires it. Khronos WebGL Specification 1.0 and Chrome for Developers

Capture the browser view when you cannot change the app

If you do not control the page or cannot change how it creates its WebGL context, capture the browser-rendered view rather than relying on a later canvas export. An extension can use a supported visible-tab capture API; the html2canvas FAQ lists chrome.tabs.captureVisibleTab() for Chrome, Edge, and Opera. A real-browser automation workflow with Puppeteer or Playwright is another option for server-side screenshots. Check the current API and permissions for your chosen browser and tool before implementing it; capture behavior and available APIs are not identical across browsers. html2canvas FAQ

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

A browser-level screenshot represents the visible view at capture time. It is a different result from directly exporting canvas pixels: the browser screenshot can include surrounding page content, while the canvas export gives you the canvas image itself.

Use html2canvas only when DOM reconstruction is suitable

html2canvas can render a DOM section into a canvas and export it, with crop and scale options. Its documentation explains that it reconstructs the image using page DOM and style information rather than taking an actual browser screenshot; it may not exactly match the real browser representation. Do not rely on it for pixel-accurate WebGL output. Cross-origin content and differences in browser rendering can also limit what appears in the generated image. See the html2canvas documentation, examples, and FAQ.

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

Account for alpha and transparency

If the canvas output has unexpected color around transparent areas, check the WebGL context’s premultipliedAlpha behavior and the image format you export. The WebGL specification notes that toDataURL() may need to de-multiply color values when the output format does not specify premultiplied alpha, and that operation is lossy. Decide whether you need a transparent background or an opaque composite, and validate the exported image in the format and viewer that will consume it. Khronos WebGL Specification 1.0

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot blank, stale, or inaccurate captures

  • The export is blank or shows an old frame: move the export closer to the draw call for the desired frame. Check whether it happens after the browser has composited or cleared the drawing buffer. If later capture is required, consider preservation at context creation or a synchronous drawing-buffer/framebuffer approach.
  • preserveDrawingBuffer appears to have no effect: verify it was included in the first getContext() call. Context attributes cannot be changed on an already-created context.
  • toBlob() returns null: treat this as a failed export, then inspect frame timing and whether the canvas still contains the intended pixels. Try exporting at the point of rendering rather than later.
  • Colors or transparency look different: account for the WebGL context’s alpha handling and the export format’s alpha expectations; de-multiplication can be lossy.
  • html2canvas omits or misrenders WebGL or external content: it reconstructs from DOM and style information, not from the browser’s final pixels. Switch to direct canvas export when you control the canvas, or a browser screenshot when you need the rendered tab.

Or skip the browser setup

For a rendered website screenshot, ScreenshotNeo offers a one-request API; it is not a substitute for exporting pixels from a WebGL app you control when you specifically need the canvas buffer. Its screenshot workflow accepts cookie banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses report the page verdict and billing status in headers. ScreenshotNeo also provides an MCP server with screenshot tools for AI agents.

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 example, using the API key and target URL:

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

See the ScreenshotNeo documentation for request options. Free includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. ScreenshotNeo is available at the free sign-up page.

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.

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.