Features Full Page Screenshot Wait for Selector & Delay Block Cookie Banners Custom Viewport & Device Website to PDF HTML to Image MCP Server Use Cases Link Previews Visual Regression Testing Screenshots for AI Agents Pricing Docs Blog Log In Sign Up

Playwright vs Screenshot API — Which One to Use?

Playwright has won the browser automation war. With 57 million weekly npm downloads — five times Puppeteer's numbers — it's the default tool for web testing in 2026. Anyone looking for a Playwright alternative for screenshots should first understand what makes Playwright great and where it falls short. Multi-browser support, built-in auto-waiting, a proper test runner, and SDKs for four languages make it genuinely excellent at what it was designed for.

But there's a gap between "great testing tool" and "reliable screenshot service." Developers who already use Playwright for testing naturally reach for it when they need to generate screenshots as a product feature — link previews, PDF reports, social cards. That's when they discover that running a Playwright screenshot API in production is a different problem entirely. The 2 GB Docker image, the memory crashes at concurrency, the font rendering differences across environments — these don't matter in a test suite running on CI. They matter a lot when a screenshot API vs self-hosted decision affects thousands of production requests.

This comparison covers when self-hosted Playwright makes sense for screenshots versus when a managed API is the faster path. For a similar breakdown focused on Puppeteer specifically, see the Puppeteer vs screenshot API comparison.

What makes Playwright different from Puppeteer for screenshots

Before comparing Playwright to an API, it helps to understand why developers pick Playwright over Puppeteer in the first place. The advantages are real:

  • Three browsers from one API — Chromium, Firefox, and WebKit. Puppeteer only speaks Chrome.
  • Auto-waiting — locators re-evaluate on every interaction, eliminating the timing bugs that cause blank screenshots in Puppeteer.
  • Built-in test runner@playwright/test with parallel execution, retries, HTML reporter, and toHaveScreenshot() for visual comparisons.
  • Four language SDKs — JavaScript, Python, Java, and .NET.
  • Open source, free forever — Apache 2.0 license, backed by Microsoft, no per-screenshot cost.

None of that is in question. Playwright is the better browser automation library. The question is whether browser automation is the right approach for screenshot generation at scale, or whether a managed screenshot API handles the job with less overhead.

The 2 GB Docker image problem

Playwright's multi-browser promise is also its weight penalty. The official Playwright screenshot Docker image ships Chromium, Firefox, and WebKit together — roughly 2 GB. Even the Chromium-only variant runs around 684 MB. Compare that to a screenshot API call that transfers a few kilobytes of JSON.

In CI/CD pipelines, that 2 GB image means slower pulls, higher storage costs, and longer startup times. In production, it means larger container footprints and slower scaling. When traffic spikes hit, new instances wait for a 2 GB download before serving their first request. That's not a minor inconvenience — it's a scaling bottleneck that compounds under load.

Multiple GitHub issues (#10168, #17408, #29356) document developers trying to reduce the image size. The workarounds — installing only Chromium, stripping unused dependencies, building custom base images — all add engineering time that has nothing to do with actually taking screenshots.

Memory management: when 8 GB isn't enough

Each Chromium tab that Playwright controls consumes roughly 200-400 MB of RAM. Open ten concurrent pages for parallel screenshot generation and the server needs 2-4 GB just for Chrome processes — before counting the Node.js runtime, the operating system, or anything else running on the machine.

A well-known production war story documents how an 8 GB server locked up overnight running Playwright screenshots. The problem wasn't a single request — it was concurrency without limits. Without a semaphore or pool pattern capping concurrent browsers to 3-4 per 8 GB, memory pressure builds until the OOM killer terminates the process.

There are subtler issues too. Playwright version 1.40.1 showed 70% higher memory usage than 1.39.0 (5.4 GB vs 3.2 GB after seven minutes of operation), documented in GitHub issue #28942. Refreshing a page every second can push the Node.js process alone past 400 MB within 20 minutes. Memory leaks from unclosed browser contexts, orphaned page objects, and stale WebSocket connections accumulate over time.

A managed screenshot API handles all of this behind the scenes. The concurrency, the memory limits, the process recycling — none of it becomes the application developer's problem. If Playwright screenshots feel slow or unstable under load, that's typically a sign that the use case has outgrown self-hosting.

Cross-platform rendering: the deepest pain point

This is the problem that burns the most engineering time and rarely has a clean fix.

Fonts render differently on Linux versus macOS versus Windows. Sub-pixel anti-aliasing varies by operating system, GPU availability, and headless mode settings. A screenshot taken on a developer's Mac won't match the same screenshot taken in a Docker container on Linux — even with identical viewport sizes and the same Playwright version. This is why Playwright screenshots look different across environments, and it's one of the most common complaints in the issue tracker.

One developer documented a 428-day battle against flaky Playwright screenshots. Even identical Docker images running on different machines produced subtle text rendering differences (GitHub issue #35143). The accepted workaround — running everything in Docker with deviceScaleFactor: 1 and scale: "css" — reduces the problem but doesn't eliminate it.

For visual regression testing of an application's own UI, this is manageable — teams pin the CI environment and accept some threshold of pixel difference. For generating screenshots of third-party websites as a product feature, it means unpredictable output quality that varies with the infrastructure running underneath.

Playwright vs screenshot API: side-by-side comparison

Aspect Playwright (self-hosted) Screenshot API
Setup time Hours to days (Docker, fonts, memory tuning) Minutes (API key + one HTTP call)
Infrastructure Servers, Docker, process management None — managed service
Scaling Manual (add servers, tune concurrency) Automatic
Cost at 5K/mo $20-50 server + engineering time $9/mo (screenshotrun)
Cost at 50K/mo $100-200 server + engineering time $99/mo (screenshotrun)
Full-page capture Yes Yes
PDF generation Yes (page.pdf()) Yes
Custom viewport Yes Yes
Wait-for-selector Yes (locator API) Yes
Cookie banner blocking Manual scripting per site One parameter
HTML to image Possible (host HTML, then screenshot) Yes (direct HTML input)
Multi-browser Yes (Chromium, Firefox, WebKit) No (Chromium typically)
Complex interactions Yes (click, fill, scroll, hover) Limited (wait, delay, basic clicks)
MCP server for AI agents Via Playwright MCP (Microsoft) Yes (screenshotrun first-party)
Maintenance burden High (updates, crashes, memory, fonts) Zero

The code difference: setup complexity vs one API call

A production-ready Playwright screenshot service needs more than page.screenshot(). It needs concurrency control, error handling, browser lifecycle management, and cleanup. Here's what that looks like:

// Playwright: production screenshot with concurrency control
const { chromium } = require('playwright');
const { Semaphore } = require('async-mutex');
const semaphore = new Semaphore(3); // max 3 browsers on 8GB server

async function takeScreenshot(url) {
  const [, release] = await semaphore.acquire();
  let browser;
  try {
    browser = await chromium.launch();
    const page = await browser.newPage({
      viewport: { width: 1280, height: 720 }
    });
    await page.goto(url, { waitUntil: 'networkidle', timeout: 30000 });
    const buffer = await page.screenshot({ fullPage: true });
    return buffer;
  } finally {
    if (browser) await browser.close();
    release();
  }
}

Plus the Dockerfile:

FROM mcr.microsoft.com/playwright:v1.61.0-noble
# ~2GB image with all browsers
RUN apt-get update && apt-get install -y fonts-noto fonts-liberation
COPY . /app
WORKDIR /app
RUN npm ci
CMD ["node", "server.js"]

The equivalent with a screenshot API:

const response = await fetch(
  `https://api.screenshotrun.com/screenshot?` +
  `url=${encodeURIComponent(targetUrl)}&full_page=true&width=1280`,
  { headers: { 'Authorization': 'Bearer API_KEY' } }
);
const image = await response.arrayBuffer();

Both produce the same output. One requires infrastructure. The other requires an API key.

When Playwright is the right choice for screenshots

Playwright genuinely wins in several scenarios:

  • Visual regression testing of your own app — comparing before/after screenshots across pull requests. A screenshot API can't access localhost or staging behind a firewall. Playwright's toHaveScreenshot() with built-in diffing is purpose-built for this workflow.
  • Multi-browser verification — when a feature needs to render correctly in Firefox and Safari, not just Chrome. Screenshot APIs typically run Chromium only.
  • Complex interaction flows — clicking through a multi-step wizard, filling forms, hovering over tooltips, then capturing the result. An API's wait-for-selector handles dynamic content, but it can't replicate a 15-step user journey.

There are also situations where the economics favor self-hosting. At extreme volume (100K+ screenshots per month), teams with existing DevOps capacity spend less on infrastructure than on API fees. And in offline or air-gapped environments where no external API calls are permitted by policy, self-hosted Playwright is the only option. Running Playwright screenshot serverless on AWS Lambda is technically possible but adds cold start latency and image size constraints that often negate the convenience.

When a screenshot API is the better Playwright alternative for screenshots

A managed API fits better when:

  • Screenshots are a feature, not the product — generating link previews, social cards, or PDF reports. The goal is reliable output, not browser control. An API delivers that without the Docker, memory, and font overhead.
  • The team is small — solo developers and startups don't have a DevOps person to debug Chromium crashes at 3 AM. A $9/month API replaces days of infrastructure work.
  • Consistent rendering matters — the API runs in a controlled environment with consistent fonts and settings. No cross-platform flakiness, no "works on my machine" screenshots.
  • Cookie banners need blocking — Playwright requires custom scripting for each consent implementation. screenshotrun handles it with a single block_cookies parameter.
  • AI agents need screenshots — LLMs that need to "see" web pages work best with a simple tool call. screenshotrun's MCP server integrates directly with AI agent workflows — simpler than configuring Playwright as an agent tool.

200 free screenshots/month, no credit card

Try screenshotrun free

The bottom line: testing tool vs screenshot service

Playwright is an extraordinary browser automation library — the best available by most measures. For testing, it's earned its dominant position. But "best testing tool" and "best way to generate screenshots at scale" are different claims.

Using Playwright for screenshot generation means taking on Docker image management, memory tuning, concurrency control, font installation, cross-platform rendering inconsistencies, and all the production infrastructure that comes with running headless browsers. For teams that already manage this infrastructure for testing, adding screenshot generation is incremental. For everyone else, it's a significant engineering investment for what could be a single API call.

Here's the practical test: if the screenshot functionality would take more than a day to set up and the team doesn't already run Playwright in production, a managed API will ship faster and stay simpler. screenshotrun offers 200 free screenshots per month to test the approach — enough to validate whether the API handles the target use case before committing either way.

For a similar breakdown focused on Puppeteer, see the Puppeteer vs screenshot API comparison. For a broader look at managed options, the best screenshot API 2026 comparison covers eight providers. And for teams already committed to self-hosting, the wait for page to fully load guide covers the timing issues that cause most blank screenshots.

Frequently asked questions

For new projects, yes. Playwright supports Chromium, Firefox, and WebKit from a single API, has better auto-wait mechanisms that reduce blank screenshots, and gets consistent updates from Microsoft. However, the production challenges — Docker image size, memory management, cross-platform rendering — are identical for both libraries. The choice between Playwright and Puppeteer doesn't change the self-hosted vs managed API tradeoff.
Each Chromium tab consumes 200-400 MB of RAM. For parallel screenshot generation, plan for 3-4 concurrent browsers per 8 GB of server memory. Without concurrency limits (semaphore or pool pattern), memory pressure builds until the OS kills the process. Version updates can also change memory usage significantly — Playwright 1.40.1 used 70% more memory than 1.39.0.
Technically yes, but with significant friction. The Chromium-only Playwright package runs around 684 MB, which fits in Lambda's 10 GB limit but causes 3-5 second cold starts. You need at least 1-2 GB memory allocation, and the 15-minute timeout limits long-running captures. For serverless-style pricing without managing browser infrastructure, a managed screenshot API is a more practical fit.
Font rendering, sub-pixel anti-aliasing, and headless mode settings vary across operating systems and hardware. A screenshot on macOS won't match the same page captured in a Linux Docker container — even with identical viewport sizes and Playwright versions. The accepted workaround is pinning everything to Docker with deviceScaleFactor: 1, but subtle differences persist. A managed API avoids this by running in a controlled, consistent environment.
Use a managed API when screenshots are a product feature (link previews, social cards, PDF reports) rather than a testing tool, when the team lacks DevOps capacity for browser infrastructure, when consistent cross-platform rendering matters, or when volume is under 100K screenshots per month. The API eliminates Docker image management, memory tuning, font installation, and concurrency control — trading infrastructure work for a predictable monthly cost.