October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Node.js

How to Take an RGBA Screenshot With Puppeteer

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

Use Puppeteer’s page.screenshot() with omitBackground: true and save the result as a PNG. That combination removes the browser’s default white backdrop and preserves transparent pixels in the PNG alpha channel:

const png = await page.screenshot({
  path: 'screenshot.png',
  type: 'png',
  omitBackground: true,
});

The option does not remove a background that your page explicitly paints with CSS or an image. If the file still looks opaque, inspect the target element and its ancestors for those backgrounds.

What RGBA means in a Puppeteer screenshot

RGBA pixels contain red, green, blue and alpha channels. The alpha channel controls how transparent a pixel is when another image or page is placed behind it. Puppeteer’s documented control is omitBackground: the ScreenshotOptions reference describes it as hiding the default white background and allowing screenshots with transparency.

This is backdrop omission, not automatic background removal. Foreground text, logos and other rendered content normally remain fully opaque. Pixels where Puppeteer would otherwise supply the browser’s default backdrop can become transparent. A background-color, gradient, covering element or background image supplied by page CSS remains part of the rendered scene.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Prerequisites and a minimal working script

Install Puppeteer in a Node.js project, then launch a browser, navigate to the page and capture a PNG:

npm install puppeteer
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
const page = await browser.newPage();

await page.goto('https://example.com', {
  waitUntil: 'networkidle2',
});

await page.screenshot({
  path: 'screenshot.png',
  type: 'png',
  omitBackground: true,
});

await browser.close();

The official Puppeteer screenshots guide demonstrates the same navigation-then-capture flow. Choose a navigation wait condition that matches the application. A single page load event does not guarantee that a client-rendered chart, image or component has finished drawing.

Use an explicit readiness condition when needed

For pages that render asynchronously, wait for a selector or another condition your application controls before taking the shot:

await page.goto('https://example.com/dashboard', {
  waitUntil: 'domcontentloaded',
});
await page.waitForSelector('[data-report-ready]');

await page.screenshot({
  path: 'dashboard.png',
  type: 'png',
  omitBackground: true,
});

Use a deliberate delay only when the page has no reliable readiness signal. Waiting for the correct state is more dependable than assuming a fixed delay covers every network request and animation.

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.

Choose how the PNG is returned

The Page.screenshot() method supports three useful output patterns.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Write a file

Set path to write the image directly. A .png extension communicates the intended format, and explicitly setting type: 'png' removes ambiguity:

await page.screenshot({
  path: './artifacts/hero.png',
  type: 'png',
  omitBackground: true,
});

Keep PNG bytes in memory

Omit path when another part of your Node.js program will upload or transform the image. Puppeteer returns a Uint8Array by default:

const pngBytes = await page.screenshot({
  type: 'png',
  omitBackground: true,
});

console.log(pngBytes instanceof Uint8Array);

Request base64 explicitly

Ask for a base64 string only when the receiving API or data format requires it:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const pngBase64 = await page.screenshot({
  type: 'png',
  omitBackground: true,
  encoding: 'base64',
});

Base64 is an encoding of the PNG; it does not change the alpha behavior. The transparency decision is made by omitBackground and the page’s own rendered styles.

Capture one transparent element instead of the whole page

For a logo, icon or card, select the element and call ElementHandle.screenshot():

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.
const logo = await page.$('.brand-mark');
if (!logo) {
  throw new Error('The .brand-mark element was not found');
}

await logo.screenshot({
  path: 'brand-mark.png',
  type: 'png',
  omitBackground: true,
});

Puppeteer scrolls the element into view before capturing it, according to the ElementHandle documentation. The handle must still refer to an attached DOM node. Frameworks that replace a component can detach the original node between selection and capture; select it again immediately before the screenshot if that occurs.

Why the result still has a white or colored background

The page paints the background itself

Inspect the computed styles of the target and its ancestors. A body rule such as body { background: #fff; }, a full-viewport wrapper, a pseudo-element or a background image is real page content. omitBackground does not delete any of those layers. Remove or override the style before capture if a transparent canvas is the desired design.

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

A covering element is above the content

Cookie notices, modal backdrops and other overlays can cover the area you expect to be transparent. Hide or remove the overlay in the page you control, or capture after the overlay is dismissed.

The format is not PNG

Use type: 'png' or a .png path. Letting a different format be inferred can produce an output that cannot retain the alpha channel you need.

Full-page and viewport considerations

The same transparency options apply whether you capture the current viewport or request a full-page image. Set the viewport before navigation when layout depends on screen size:

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
await page.setViewport({ width: 1440, height: 900, deviceScaleFactor: 1 });
await page.goto('https://example.com', { waitUntil: 'networkidle2' });

await page.screenshot({
  path: 'page.png',
  type: 'png',
  omitBackground: true,
  fullPage: true,
});

A full-page image can include sections that were not visible initially. Ensure lazy content has loaded before capture; otherwise the transparent PNG may faithfully record empty placeholders rather than the finished page.

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

Common errors and fixes

Symptom Likely cause Fix
White background remains CSS background, image or overlay is explicitly rendered. Inspect computed backgrounds and covering elements; remove or override them before the screenshot.
Output has no transparency The capture was encoded as a format or path other than PNG. Set type: 'png' and use a .png path.
Code expects a string but receives binary data The default return value is a Uint8Array. Consume the bytes directly or set encoding: 'base64' when a base64 string is required.
ElementHandle.screenshot() throws The selected node was detached from the DOM. Wait for the component to settle and obtain a fresh handle immediately before capture.
Element appears missing The element was not present when the selector ran. Wait for a reliable selector or application-ready signal, then select it again.
Images or content are incomplete Capture started before asynchronous rendering finished. Use an appropriate waitUntil value plus waitForSelector or another page-specific readiness check.

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server when you do not want to maintain a Puppeteer launch, wait logic and browser runtime. Its transparent-background option is designed for this kind of capture, and it also supports full-page shots, CSS-selector element capture, custom CSS and JavaScript, click-before-capture actions, selector or network-idle waits, viewport and device presets, retina scale, cookies, headers, user agents, authorization, timezone and geolocation.

Each request below uses the documented endpoint and parameter names. See the ScreenshotNeo documentation for the available capture options.

cURL

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}`);
const buffer = Buffer.from(await res.arrayBuffer());

ScreenshotNeo removes cookie and consent banners, newsletter popups and chat widgets before capture; each step can be switched off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and whether the request was billed. An MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.

The Free plan includes 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots; Growth is $15 for 15,000, Pro $39 for 60,000, Scale $99 for 250,000 and Business $249 for 1,000,000. Yearly billing gives two months free, and every feature is included on every plan. Create a free ScreenshotNeo account to start.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Operational guidance

Close the browser in every execution path

Use a try/finally pattern in production so a navigation or selector error does not leave a browser process running:

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.goto('https://example.com', { waitUntil: 'networkidle2' });
  await page.screenshot({
    path: 'transparent.png',
    type: 'png',
    omitBackground: true,
  });
} finally {
  await browser.close();
}

Separate readiness from image encoding

First make the page deterministic: set the viewport, navigate, wait for the application’s ready state and verify the target exists. Then capture with PNG and omitBackground. This separation makes failures easier to diagnose than changing several screenshot options at once.

FAQ

Can I produce a full-page image and an element image from the same page?

Yes. Keep the page open, call page.screenshot() for the page-level asset, then obtain the current element handle and call element.screenshot() for the focused asset. If the framework rerenders between calls, select the element again.

How do I preserve alpha when sending the result to another service?

Keep Puppeteer’s PNG bytes unchanged, or request encoding: 'base64' when the receiving interface requires text. Do not transcode the image to a format that lacks an alpha channel.

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

Frequently Asked Questions

Can I produce a full-page image and an element image from the same page?

Yes. Capture the page with page.screenshot(), then select the current DOM node and call element.screenshot(). Re-select the node if your framework rerenders it.

How do I preserve alpha when sending the result to another service?

Keep the PNG bytes unchanged, or request encoding: ‘base64’ when text is required. Avoid transcoding to a format without an alpha channel.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Read next

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.