Puppeteer and Playwright let you control a real browser from code. So both have the ability to scrape pages that only show their content after JavaScript runs. With that much overlap, which one should you use?
Here's the short answer:
- Pick Playwright for most new scraping projects. It supports Python, Java, and .NET as well as JavaScript, runs Chromium, Firefox, and WebKit, and waits for elements by default.
- Pick Puppeteer if you only need Chrome or Firefox, work in JavaScript, and want a smaller API that stays close to Chrome. It's also the right call if you already have Puppeteer scripts that work.
- Pick neither if the data is in the page's static HTML or on a search engine. A browser is the slowest way to get that data.
The rest of this post shows the differences, the same scraper written in both libraries, and how to skip the browser when you can. If you're new to scraping with Node.js, start with this guide:

Puppeteer vs Playwright at a glance
Here's how the two compare on the things that matter most for scraping.
| Puppeteer | Playwright | |
|---|---|---|
| Maintained by | Google (Chrome team) | Microsoft |
| Languages | JavaScript, TypeScript | JavaScript, TypeScript, Python, Java, .NET |
| Browsers | Chrome, Firefox | Chromium, Firefox, WebKit (Safari's engine) |
| Waiting for elements | Locators wait automatically. page.$() and page.$eval() don't |
Locators wait automatically, and they are the default way to select |
| XPath | ::-p-xpath(//h2) |
xpath=//h2, or any selector starting with // |
| Test runner | None built in | Playwright Test, with codegen and trace viewer |
| AI agents (MCP) | Used by Google's Chrome DevTools MCP for browser input | Official Playwright MCP server from Microsoft |
| Version we tested | 25.19.0 | 1.65.1 |
Browsers
Puppeteer started as a Chrome-only tool. Since version 23 it also works with stable Firefox through WebDriver BiDi. Playwright adds WebKit, which is the closest you can get to Safari without a Mac. For scraping, Chrome is usually enough. Cross-browser support matters more for testing.
Languages
This is the biggest practical difference. Puppeteer is JavaScript only. If your team writes Python, Playwright gives you the same API there, and you don't need an unofficial port. We cover the Python side in our Python web scraping libraries roundup.
Waiting
Flaky scrapers usually come from reading the page before the data is there. Playwright's locators wait for an element to be ready before acting on it. Puppeteer added a similar Locator API (page.locator()), but most Puppeteer code and tutorials still use page.$() and page.waitForSelector(), where waiting is your job.
Popularity
In Google Trends (Computers & Electronics category, past 5 years), search interest in Playwright passed Puppeteer in 2023. By late 2026, Playwright averaged about 7 times Puppeteer's level. Puppeteer is still actively released, though. Version 25 came out in May 2026.

The same scraper in Puppeteer and Playwright
The best way to see the difference is to write the same scraper twice. Both scripts below scrape the Oscar Winning Films page on Scrape This Site, a public sandbox for practicing web scraping. The films only load with AJAX after you click a year, so an HTML parser on the raw page finds none.

Each script:
- Opens the page and reads the list of years.
- Clicks a year and waits for its films to load.
- Collects the title, nominations, awards, and Best Picture flag of each film.
- Repeats for up to
MAX_YEARSyears. - Prints progress and saves the results to a JSON file.
The scraped data is identical across both.
Both scripts use import and top-level await. To run them as regular .js files, create a project folder and set it to use ES modules:
mkdir films-scraper && cd films-scraper
npm init -y
npm pkg set type=moduleThis adds "type": "module" to your package.json.
Puppeteer
Install Puppeteer. It downloads a matching version of Chrome for you:
npm install puppeteerSave this as scrape-puppeteer.js:
import puppeteer from "puppeteer";
import { writeFile } from "node:fs/promises";
const URL = "https://www.scrapethissite.com/pages/ajax-javascript/";
const MAX_YEARS = 3; // stop after 3 years
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(URL, { waitUntil: "domcontentloaded" });
// The year links are in the HTML. The films are not.
const years = await page.$$eval("a.year-link", (links) => links.map((a) => a.id));
const films = [];
for (const year of years.slice(0, MAX_YEARS)) {
await page.click(`a.year-link[id="${year}"]`);
// The films load with AJAX. The old table stays in the page while hidden,
// so wait for a visible row, not just any row.
await page.waitForSelector("tr.film", { visible: true });
const rows = await page.$$eval("tr.film", (trs) =>
trs.map((tr) => ({
title: tr.querySelector(".film-title").textContent.trim(),
nominations: Number(tr.querySelector(".film-nominations").textContent),
awards: Number(tr.querySelector(".film-awards").textContent),
best_picture: tr.querySelector(".film-best-picture i") !== null,
}))
);
films.push(...rows.map((film) => ({ year: Number(year), ...film })));
console.log(`${year}: ${rows.length} films`);
}
await browser.close();
await writeFile("films-puppeteer.json", JSON.stringify(films, null, 2));
console.log(`Saved ${films.length} films to films-puppeteer.json`);Run it with node scrape-puppeteer.js. For a longer walkthrough, see scraping a dynamic website with Puppeteer.
Playwright
Install Playwright and the Chromium build it uses:
npm install playwright
npx playwright install chromiumSave this as scrape-playwright.js:
import { chromium } from "playwright";
import { writeFile } from "node:fs/promises";
const URL = "https://www.scrapethissite.com/pages/ajax-javascript/";
const MAX_YEARS = 3; // stop after 3 years
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto(URL, { waitUntil: "domcontentloaded" });
// The year links are in the HTML. The films are not.
const years = await page.locator("a.year-link").allInnerTexts();
const films = [];
for (const year of years.slice(0, MAX_YEARS)) {
// click() waits for the link to be visible and enabled
await page.getByRole("link", { name: year, exact: true }).click();
// evaluateAll() doesn't wait, so wait for the first film to be visible
const rowsLocator = page.locator("tr.film");
await rowsLocator.first().waitFor();
const rows = await rowsLocator.evaluateAll((trs) =>
trs.map((tr) => ({
title: tr.querySelector(".film-title").textContent.trim(),
nominations: Number(tr.querySelector(".film-nominations").textContent),
awards: Number(tr.querySelector(".film-awards").textContent),
best_picture: tr.querySelector(".film-best-picture i") !== null,
}))
);
films.push(...rows.map((film) => ({ year: Number(year), ...film })));
console.log(`${year}: ${rows.length} films`);
}
await browser.close();
await writeFile("films-playwright.json", JSON.stringify(films, null, 2));
console.log(`Saved ${films.length} films to films-playwright.json`);Run it with node scrape-playwright.js. Both scripts print the same counts. Only the file name in the last line changes:
2015: 16 films
2014: 16 films
2013: 12 films
Saved 44 films to films-playwright.jsonTo switch browsers in Playwright, change chromium to firefox or webkit and install that browser with npx playwright install. The rest of the script stays the same.
Playwright in Python
If you work in Python, Playwright has an official library with the same API. Here's the same scraper:
pip install playwright
playwright install chromiumSave this as scrape_playwright.py:
import json
from playwright.sync_api import sync_playwright
URL = "https://www.scrapethissite.com/pages/ajax-javascript/"
MAX_YEARS = 3 # stop after 3 years
films = []
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
page.goto(URL, wait_until="domcontentloaded")
years = page.locator("a.year-link").all_inner_texts()
for year in years[:MAX_YEARS]:
page.get_by_role("link", name=year, exact=True).click()
rows = page.locator("tr.film")
rows.first.wait_for()
for row in rows.all():
films.append({
"year": int(year),
"title": row.locator(".film-title").inner_text().strip(),
"nominations": int(row.locator(".film-nominations").inner_text()),
"awards": int(row.locator(".film-awards").inner_text()),
"best_picture": row.locator(".film-best-picture i").count() > 0,
})
print(f"{year}: {rows.count()} films")
browser.close()
with open("films_playwright.json", "w", encoding="utf-8") as f:
json.dump(films, f, ensure_ascii=False, indent=2)
print(f"Saved {len(films)} films to films_playwright.json")Run it with python scrape_playwright.py.
What changed between the two
- Launching. Puppeteer launches Chrome by default. Playwright makes you pick an engine (
chromium,firefox, orwebkit). - Clicking. Puppeteer finds the year link with a CSS selector. Playwright's
getByRole()finds it the way a user sees it, by its role and text, andclick()waits until the link is ready. - Waiting. Both scripts wait for the films after each click. The old table stays in the page while it's hidden, so Puppeteer needs
{ visible: true }. Without it, the script would read the previous year's rows. Playwright'swaitFor()checks for visibility by default.
For a small scraper like this, either library works, but the choice matters as the project grows. So here's when each one makes sense.
When to pick Puppeteer
- You only need Chrome or Firefox, and you work in JavaScript or TypeScript.
- You already have Puppeteer scripts that work. Rewriting them rarely pays off.
- You want direct access to the Chrome DevTools Protocol for things like network tracing or performance data. Puppeteer stays closer to Chrome.
- You're building on top of tools that use it, such as Google's Chrome DevTools MCP server.
When to pick Playwright
- You write Python, Java, or .NET, or your team mixes languages.
- You need Firefox or WebKit in addition to Chromium.
- You want auto-waiting by default to cut down on flaky scripts.
- You also write end-to-end tests and want one tool for both.
- You're giving an AI agent a browser. Microsoft's official Playwright MCP server makes this a few lines of setup.
What about Selenium
Selenium is the oldest of the three. It drives browsers through the WebDriver standard and supports the most languages. If your team already runs Selenium or needs a Selenium Grid, it's the best choice. For new scraping projects, Playwright usually needs less setup and less waiting code. We cover Selenium in our Selenium web scraping with Python tutorial, and more JavaScript options in top JavaScript web scraping libraries.
Mistakes that slow down both
Some mistakes slow down scrapers or break them, no matter which library you use. Common ones include waiting a fixed time instead of waiting for the element, loading every image when you only need text, and using long selectors copied from DevTools. Our post on avoiding Puppeteer antipatterns walks through nine of them. Most apply to Playwright too.
Do you need a browser at all
The last antipattern in that list is using a browser when a simpler tool would do. Puppeteer and Playwright launch a full browser for every job, which costs time and memory, and often requires proxies once a site starts blocking you. Before you pick either, check whether you need one.
Many pages that look dynamic still send their content in the HTML, because the server renders it first. For those, you can skip the browser. SerpApi's Extract API fetches any public page and returns its content as Markdown, along with its links and metadata, including JSON-LD. It can also map a site's URLs or crawl it page by page:
import { getJson } from "serpapi";
import { writeFile } from "node:fs/promises";
const page = await getJson({
engine: "extract",
url: "https://www.scrapethissite.com/pages/simple/",
api_key: process.env.SERPAPI_API_KEY,
});
console.log(page.page_information.title);
console.log(page.markdown);
await writeFile("countries.md", page.markdown);
console.log("Saved the page to countries.md");Install the library with npm install serpapi and set your API key as SERPAPI_API_KEY. On the static Countries of the World page, this returns all 250 countries. On the Oscar Winning Films page, it returns the heading and year links but no films, because the Extract API reads the HTML the server sends and doesn't run JavaScript. That's the quickest test: if Extract gets your data, you don't need a browser. If the data only appears after JavaScript runs, Puppeteer or Playwright is the right tool, unless the site has its own SerpApi engine.
For the full feature list, including crawl and map modes, see the launch post:

If you're scraping a search engine or marketplace, use the dedicated API instead of a headless browser. Google, Bing, Amazon, Google Maps, and many other sites have their own SerpApi engines that return structured JSON and handle blocks and CAPTCHAs for you:
import { getJson } from "serpapi";
import { writeFile } from "node:fs/promises";
const results = await getJson({
engine: "google",
q: "puppeteer vs playwright",
api_key: process.env.SERPAPI_API_KEY,
});
for (const result of results.organic_results) {
console.log(result.position, result.title, result.link);
}
await writeFile("google-results.json", JSON.stringify(results.organic_results, null, 2));
console.log("Saved the results to google-results.json");The Extract API also routes supported URLs to their dedicated engine automatically, so JavaScript-heavy sites like YouTube still come back as structured data. For example, a YouTube video URL returns the same result as the YouTube Video API.
FAQ
Which is better, Puppeteer or Playwright?
For most new scraping projects, Playwright. It supports more languages and browsers, and its locators wait for elements by default. Puppeteer is still a good choice for Chrome-focused JavaScript projects and for existing Puppeteer code.
Is Puppeteer still used?
Yes. Puppeteer is actively maintained by the Chrome team, with version 25 released in May 2026. Google's Chrome DevTools MCP server also uses it to drive the browser.
Can I use XPath in Playwright?
Yes. Use page.locator("xpath=//h2"), or pass a selector that starts with // and Playwright treats it as XPath. In Puppeteer, use page.locator("::-p-xpath(//h2)"). The older page.$x() and page.waitForXPath() methods are gone in Puppeteer 25.
Is Selenium or Playwright better for scraping?
For new projects, Playwright usually needs less code, especially for waiting. Selenium makes sense if your team already uses it or needs a Selenium Grid.
Should I use Playwright MCP or a Puppeteer MCP server for AI agents?
Microsoft's Playwright MCP server is the official, actively maintained option, and it supports Chromium, Firefox, and WebKit. On the Puppeteer side, the main option is Google's Chrome DevTools MCP, which uses Puppeteer and focuses on debugging and inspecting Chrome.
Conclusion
Playwright is the default choice for new scraping projects, mainly because of its language support and auto-waiting. Puppeteer is still a solid, actively maintained tool if you only need Chrome or Firefox in JavaScript. And before you reach for either, check whether the data is available without a browser. That's usually the fastest scraper of all.
If you have any questions, feel free to contact us.

