     [Blog](https://scrapfly.io/blog)   /  [blocking](https://scrapfly.io/blog/tag/blocking)   /  [Playwright Stealth: Bypass Bot Detection in Python &amp; Node.js](https://scrapfly.io/blog/posts/playwright-stealth-bypass-bot-detection)   # Playwright Stealth: Bypass Bot Detection in Python &amp; Node.js

 by [Ziad Shamndy](https://scrapfly.io/blog/author/ziad) Nov 16, 2026 31 min read [\#blocking](https://scrapfly.io/blog/tag/blocking) [\#headless-browser](https://scrapfly.io/blog/tag/headless-browser) [\#nodejs](https://scrapfly.io/blog/tag/nodejs) [\#python](https://scrapfly.io/blog/tag/python) 

 [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fscrapfly.io%2Fblog%2Fposts%2Fplaywright-stealth-bypass-bot-detection "Share on LinkedIn") [  ](https://x.com/intent/tweet?url=https%3A%2F%2Fscrapfly.io%2Fblog%2Fposts%2Fplaywright-stealth-bypass-bot-detection&text=Playwright%20Stealth%3A%20Bypass%20Bot%20Detection%20in%20Python%20%26%20Node.js "Share on X") [  ](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fscrapfly.io%2Fblog%2Fposts%2Fplaywright-stealth-bypass-bot-detection "Share on Facebook")    

 

 

Summarize this article with

 [  ](https://chat.openai.com/?q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fposts%2Fplaywright-stealth-bypass-bot-detection) [  ](https://claude.ai/new?q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fposts%2Fplaywright-stealth-bypass-bot-detection) [  ](https://x.com/i/grok?text=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fposts%2Fplaywright-stealth-bypass-bot-detection) [  ](https://www.perplexity.ai/search/new?q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fposts%2Fplaywright-stealth-bypass-bot-detection) [  ](https://www.google.com/search?udm=50&aep=11&q=Summarize%20this%20article%20and%20explain%20how%20Scrapfly%20helps%20me%20scrape%20any%20website%20at%20scale%20and%20bypass%20anti-bot%20systems%20for%20my%20use%20case%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fposts%2Fplaywright-stealth-bypass-bot-detection) 



         

  **Browser API**Automate browsers in the cloud with full JavaScript rendering support.

 

 [ Learn More  ](https://scrapfly.io/products/cloud-browser-api) [  Docs ](https://scrapfly.io/docs/scrape-api/javascript-rendering) 

 

 

Headless browser tools can leak specific details about the browser engine, allowing websites to identify them as controlled browsers and not normal ones.

For example, a popular headless browser leak is the `navigator.webdriver` value, which is set to `True` with automated browsers only. When we ran Playwright with Chromium 156, the User-Agent header even had `HeadlessChrome` in it!

Many of these leaks are publicly known, and many browser automation libraries have existing tools to deal with them. But what about using these tools with Playwright to scrape without getting blocked?

In this article, we'll explain Playwright stealth and how to use it in Python and Node.js to avoid web scraping blocking. We'll also fix the `stealth_sync` import error and see which leaks the patches actually hide. Let's dive in!



## Key Takeaways

When it comes to identifying web scrapers javascript is by far the most powerful tool because it allows arbitrary code execution on the client machine. This code has access to enormous amount of unique datapoints that can be used to build a client fingerprint or even instantly identify web scraper controlled browsers.

- Both tools only patch basic JavaScript leaks and headers, and they don't hide our IP address or solve challenges.
- In Python, there's `playwright-stealth` 2.0.3, which replaced the old `stealth_sync` function with the `Stealth` class.
- In Node.js, there's `playwright-extra` and the [puppeteer-stealth](https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin-stealth) plugin, which we register before launching the browser.
- Finally, for existing Playwright code, there's Scrapfly [Cloud Browser](https://scrapfly.io/products/cloud-browser-api), which connects with `connect_over_cdp()` and opens pages in `browser.contexts[0]`.

**Get web scraping tips in your inbox**Trusted by 100K+ developers and 30K+ enterprises. Unsubscribe anytime.







## How Do Websites Detect Headless Playwright?

Since websites can execute arbitrary JavaScript code on the client's side, they can extract various details about the connecting client.

Unfortunately, many web browser automation tools leak information about themselves to the JavaScript execution context. The page can tell a program is driving the browser rather than a human being.

For example, the most commonly known leak when it comes to browser automation tools like Selenium, Playwright or Puppeteer is the `navigator.webdriver` leak where an automated browser would have `navigator.webdriver` value set to an unusual value of `true`.

We launched `chromium.launch(headless=True)` with no stealth package and printed what the website receives.

```
webdriver: True
plugins: 0
User-Agent header: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/156.0.8078.4 Safari/537.36
Sec-Ch-Ua header: "Not:A-Brand";v="8", "Chromium";v="156", "HeadlessChrome";v="156"
```



Our browser had it set to `True` too, and the user agent even has `HeadlessChrome` in it. These variables can be read by any website making identification of robots extremely easy!

Scraper controlled browsers often contain extra information that indicates the browser is running without GUI elements (aka headless). Our browser had `HeadlessChrome/156.0.8078.4` in the User-Agent header and a `HeadlessChrome` brand in Sec-CH-UA.

A website can also compare these headers with `navigator.userAgent`, as all of these values should describe the same browser.

Another common leak is `navigator.plugins`, which indicates the plugins used by the browser. The default headless shell reported 0 plugins in our run, so this value depends on the build we launch.

Media codecs and WebGL strings can differ between headless and regular Chrome too.

Even when the initial connection looks like a real web browser, anti-bot systems can still detect scrapers through behavior analysis. For example, humans browse in more chaotic patterns, and they're slower and more random than bots.

So, the trust score isn't a constant number and gets adjusted based on the client's behavior.

That being said, stealth packages mainly work on those JavaScript properties and headers. We'll get back to the rest once we see why a patched browser can still get blocked.

To validate our own browser, see Scrapfly's [browser fingerprint tool](https://scrapfly.io/web-scraping-tools/browser-fingerprint), which shows the values that a website can read.

Note that properties marked in red are highly unique, so a red row doesn't mean the browser was detected.

[How Browser Fingerprinting Works and How to Defend Against ItLearn how browser fingerprinting works, from canvas to WebGPU, test your fingerprint with free tools, and apply developer-focused anti-detection strategies in your web scrapers.](https://scrapfly.io/blog/posts/how-browser-fingerprinting-works)

But what about patching these leaks? Next, let's take a look at what Playwright stealth is.



## What Is Playwright Stealth, and Which Package Do You Need?

To avoid this JavaScript fingerprinting, we can modify the browser and mock its features. Fingerprint resistance is quite a complicated topic. However, there are community-maintained web scraping tools that handle fingerprint resistance for us!

Note that Playwright itself doesn't have a stealth mode, so **Playwright stealth isn't a flag we can turn on**. The term refers to a third-party package, which is `playwright-stealth` in Python, or `playwright-extra` with `puppeteer-extra-plugin-stealth` in Node.js.

The `playwright-stealth` package is a port with its own evasion scripts. On the other hand, the Node.js setup uses the original Puppeteer stealth plugin through a Playwright wrapper.

Here's a quick comparison between the two:

| Language | Install | Latest version | Released | How to apply it |
|---|---|---|---|---|
| Python | `playwright-stealth` | 2.0.3 | April 4, 2026 | `Stealth().use_async()` / `use_sync()` |
| Node.js | `playwright-extra` + `puppeteer-extra-plugin-stealth` | 4.3.6 + 2.11.2 | March 1, 2023 | `chromium.use(StealthPlugin())` |

Note that `playwright-extra` is only available in Node.js, as pip has no package with that name.

For Python, the current code lives in the [Mattwmaster58/playwright\_stealth](https://github.com/Mattwmaster58/playwright_stealth) repository, which is the one [PyPI](https://pypi.org/project/playwright-stealth/) links to. The older Granitosaurus/playwright-stealth repository still shows the 1.x API, so we shouldn't follow its README.

There are other similar packages like `playwright-stealth-plus` on PyPI, but we'll stick with the two stacks in the table.

As for Node.js, the packages haven't had a release since March 2023. However, both packages still installed and ran on Playwright 1.64.1 in our tests.

[Puppeteer Stealth: Complete Guide to Avoiding DetectionComplete guide to puppeteer-extra-plugin-stealth for avoiding bot detection. Learn how detection works, configure stealth evasion modules, implement complementary techniques, and scale with cloud browsers.](https://scrapfly.io/blog/posts/puppeteer-stealth-complete-guide)

Before proceeding to the Node.js setup, let's start with Python.



## How Do You Set Up playwright-stealth in Python?

To prevent leaking data through javascript variables, we can patch our browser's javascript environment with fake values using javascript.

The `playwright-stealth` package does this through the `Stealth` class.

To patch these leaks in our browser automation tools we can take advantage of page initiation script functionality. For `chromium.launch()`, the wrapper also rewrites the launch flags and the request headers.

\_Tested with Python 3.13.18, playwright 1.64.1, playwright-stealth 2.0.3 and Chromium 156.0.8078.4 (default headless shell) on Ubuntu 24.04 x86*64, November 6, 2026.*

### Setup

It can be installed using the pip terminal command:

shell

```shell
pip install playwright-stealth==2.0.3
```



The above command will also install `playwright` as it's used by `playwright-stealth` under the hood.

Since version 2.0.1, the package depends on `playwright>=1.40.0`.

We're pinning 2.0.3, since an old tutorial with 1.x imports fails on the 2.x package.

After running the above command, install the Playwright headless browser binaries and dependencies:

shell

```shell
playwright install chromium
playwright install-deps chromium
```



The above command will install the related **Chrome** binaries. On our Ubuntu machine the second line added the system libraries.

### Async Example

Playwright supports both **asynchronous and synchronous** clients, whereas Selenium only supports a synchronous client and Puppeteer an asynchronous one.

To start, we need to launch a browser and start a new browser tab. This one prints the page title and the first five products.

python

```python
import asyncio

from playwright.async_api import async_playwright
from playwright_stealth import Stealth


async def main():
    async with Stealth().use_async(async_playwright()) as playwright:
        browser = await playwright.chromium.launch(headless=True)
        page = await browser.new_page()
        await page.goto("https://web-scraping.dev/products")
        print(f"Page title: {await page.title()}")

        products = await page.evaluate("""
            Array.from(document.querySelectorAll('.product')).slice(0, 5).map(item => ({
                title: item.querySelector('h3 a')?.textContent?.trim(),
                price: item.querySelector('.price')?.textContent?.trim()
            }))
        """)
        for product in products:
            print(f"{product['title']}: {product['price']}")

        await browser.close()


asyncio.run(main())
```



Here is what we got:

```
Page title: web-scraping.dev product page 1
Box of Chocolate Candy: 24.99
Dark Red Energy Potion: 4.99
Teal Energy Potion: 4.99
Red Energy Potion: 4.99
Blue Energy Potion: 4.99
```



Since Playwright uses a real web browser with javascript environment we can use the browser's HTML parsing capabilities.

We wrap `async_playwright()` with `Stealth().use_async()`, and every page opened in the block gets the patch.

The above code will attach our `navigator.webdriver` fix script to page/browser initiation process which will plug this leak for the entire scraping session!

### Sync Example

In Playwright, we can write small scrapers using synchronous clients and scale up simply by switching to a more complex asynchronous architecture.

Using context we can define page properties like viewport dimensions.

python

```python
from playwright.sync_api import sync_playwright
from playwright_stealth import Stealth

with Stealth().use_sync(sync_playwright()) as playwright:
    browser = playwright.chromium.launch(headless=True)
    context = browser.new_context(viewport={"width": 1920, "height": 1080})
    page = context.new_page()

    page.goto("https://web-scraping.dev/products")
    page.wait_for_selector(".product")
    print(f"Page title: {page.title()}")

    browser.close()
```



To navigate we can use `page.goto()` function which will direct the browser to any URL. Above, we used `page.wait_for_selector()` function to wait for an element defined by our CSS selector to appear on the page.

It printed the same page title.

Since version 2.0.1, a second stealth call on the same page warns and gets skipped.

### Applying Stealth Manually

Browsers are very complex software suites and to deal with this complexity every browser can be customized via launch flags.

Unfortunately, browser automation tools often add extra launch flags that can lead to unusual browser behavior which results in identity leak. Let's take a look at some of them.

`apply_stealth_async()` only adds the init script. The context manager is what rewrites the headers and launch flags.

When it comes to javascript we want to ensure that **header values match the browser capabilities**.

python

```python
import asyncio
import json

from playwright.async_api import async_playwright
from playwright_stealth import Stealth


async def main():
    stealth = Stealth()
    async with async_playwright() as playwright:
        browser = await playwright.chromium.launch(headless=True)
        context = await browser.new_context()
        await stealth.apply_stealth_async(context)

        page = await context.new_page()
        await page.goto("https://httpbin.dev/headers")
        headers = json.loads(await page.inner_text("body"))["headers"]

        print("navigator.userAgent:", await page.evaluate("navigator.userAgent"))
        print("User-Agent header:", headers["User-Agent"][0])
        print("Sec-Ch-Ua header:", headers["Sec-Ch-Ua"][0])

        await browser.close()


asyncio.run(main())
```



Here is what we got:

```
navigator.userAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/156.0.8078.4 Safari/537.36
User-Agent header: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/156.0.8078.4 Safari/537.36
Sec-Ch-Ua header: "Not:A-Brand";v="8", "Chromium";v="156", "HeadlessChrome";v="156"
```



Playwright's `user_agent` context option changes both the HTTP User-Agent header and `navigator.userAgent`; check Client Hints and platform values separately.

Our headers still said `HeadlessChrome`.

So, when using a headless browser for web scraping we want to ensure that we mimic the headful browser for these values.

Next we ran the same page with `Stealth().use_async()` and no `apply_stealth_async()` call.

```
navigator.userAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/156.0.8078.4 Safari/537.36
User-Agent header: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/156.0.8078.4 Safari/537.36
Sec-Ch-Ua header: "Not;A_Brand";v="99", "Chrome";v="156", "Chromium";v="156"
```



The `Sec-CH-` family of headers is *a new and experimental* take on user agent strings implemented by newer browser versions.

These headers essentially contain the same data available in User-Agent header so it's important to match the values of these two headers to not get identified as a web scraper.

The context manager does not wrap `launch_persistent_context()` in 2.0.3; its pages remain unpatched unless stealth is applied manually:

```
launch_persistent_context() inside Stealth().use_async()
navigator.webdriver: true
plugins: 0
```



Above, we see that the controlled browser has `navigator.webdriver` set to `true` where natural browsers always have it set to `false`. These variables can be read by any website making identification of robots extremely easy!

```
apply_stealth_async() on that context
navigator.webdriver: false
User-Agent header: HeadlessChrome/156.0.8078.4
```



Unfortunately, since web browsers change rapidly open source libraries often lag behind as it takes a lot of volunteer effort to keep up.

If you'd like to learn more see our other introduction articles:

[Web Scraping With Playwright in 2026: A Python GuideScrape JavaScript-rendered pages with Playwright and Python in 2026: locators, waiting, request interception, resource blocking, and concurrency.](https://scrapfly.io/blog/posts/web-scraping-with-playwright-and-python)

Old tutorials still fail on the 2.x import names, so let's fix that error next.



## How Do You Fix "cannot import name 'stealth\_sync' from 'playwright\_stealth'"?

First, we import the libraries we will use.

python

```python
from playwright_stealth import stealth_sync, stealth_async
```



Here is what we got:

```
ImportError: cannot import name 'stealth_sync' from 'playwright_stealth'
ImportError: cannot import name 'stealth_async' from 'playwright_stealth'
```



Version 2.0.0 [renamed the public API](https://github.com/Mattwmaster58/playwright_stealth/blob/main/CHANGELOG.md), so `stealth_sync`, `stealth_async` and `StealthConfig` no longer exist.

Now, that we know what failure looks like let's bypass this challenge using the `Stealth` class:

python

```python
from playwright_stealth import Stealth
```



| Old API | Context manager | Manual application |
|---|---|---|
| `stealth_async(page)` | `Stealth().use_async(async_playwright())` | `await Stealth().apply_stealth_async(page)` |
| `stealth_sync(page)` | `Stealth().use_sync(sync_playwright())` | `Stealth().apply_stealth_sync(page)` |
| `StealthConfig(...)` | Keyword arguments on `Stealth(...)` | Keyword arguments on `Stealth(...)` |

```
ModuleNotFoundError: No module named 'playwright_stealth'
```



This error means something went wrong with `playwright_stealth` installation. This usually happens when `pip install` installs the package to a different python environment. So, ensure that `python` and `pip` point to the same Python environment.

Run `python -m pip show playwright-stealth` with that same `python`.

Now, let's take a look at the Node.js setup.



## How Do You Use Playwright Stealth in Node.js and TypeScript?

Since we scrape with a web browser, the websites can use various JavaScript scripts to gather information about the client. This can leak the fact that the requests are automated!

To avoid this JavaScript fingerprinting, we can configure Playwright and mock its features. Fingerprint resistance is quite a complicated topic. However, there are community-maintained web scraping tools that manage it for us!

We import `chromium` from [playwright-extra](https://github.com/berstend/puppeteer-extra/tree/master/packages/playwright-extra) and call `chromium.use(StealthPlugin())` before `launch()`.

For example, the most commonly known leak when it comes to browser automation tools like Selenium, Playwright or Puppeteer is the `navigator.webdriver` leak where an automated browser would have `navigator.webdriver` value set to an unusual value of `true`:

javascript

```javascript
const { chromium } = require('playwright');
const { chromium: extraChromium } = require('playwright-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');

(async () => {
    extraChromium.use(StealthPlugin());
    const browser = await chromium.launch({ headless: true });
    const page = await browser.newPage();
    console.log('navigator.webdriver:', await page.evaluate(() => navigator.webdriver));
    await browser.close();
})();
```



Here is what we got:

```
navigator.webdriver: true
```



Above, we see that the controlled browser has `navigator.webdriver` set to `true` where natural browsers always have it set to `false`. These variables can be read by any website making identification of robots extremely easy!

The plugin was registered on `playwright-extra`, and `launch()` used the plain `playwright` import.

javascript

```javascript
const { chromium } = require('playwright');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');

chromium.use(StealthPlugin());
```



Here is what we got:

```
TypeError: chromium.use is not a function
```



That import is plain `playwright`.

### Setup

Install the Playwright packages with npm:

shell

```shell
npm install playwright@1.64.1 playwright-extra puppeteer-extra-plugin-stealth
npx playwright install chromium
```



On this run we used Node.js 26.12.1, Playwright 1.64.1, playwright-extra 4.3.6 and puppeteer-extra-plugin-stealth 2.11.2.

The above command will install playwright package and playwright browser binaries. Use Chromium for these stealth examples; the plugin is optimized for Chromium-based browsers.

### ESM and CommonJS

Note that we'll execute our Playwright web scraping code asynchronously with the context of promises, and async/await programming.

The Playwright examples below open the product page and print product names and prices:

ESM

CommonJS

javascript

```javascript
// stealth-scraper.mjs
import { chromium } from 'playwright-extra';
import StealthPlugin from 'puppeteer-extra-plugin-stealth';

chromium.use(StealthPlugin());

(async () => {
    const browser = await chromium.launch({ headless: true });
    const context = await browser.newContext({
        viewport: { width: 1920, height: 1080 }
    });
    const page = await context.newPage();

    const response = await page.goto('https://web-scraping.dev/products');
    await page.waitForSelector('.product');
    console.log('Status:', response?.status());

    const products = await page.evaluate(() => {
        return Array.from(document.querySelectorAll('.product')).map(item => ({
            title: item.querySelector('h3 a')?.textContent?.trim(),
            price: item.querySelector('.price')?.textContent?.trim()
        }));
    });

    console.log(products);
    await browser.close();
})();
```





javascript

```javascript
// stealth-scraper.cjs
const { chromium } = require('playwright-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');

chromium.use(StealthPlugin());

(async () => {
    const browser = await chromium.launch({ headless: true });
    const context = await browser.newContext({
        viewport: { width: 1920, height: 1080 }
    });
    const page = await context.newPage();

    const response = await page.goto('https://web-scraping.dev/products');
    await page.waitForSelector('.product');
    console.log('Status:', response?.status());

    const products = await page.evaluate(() => {
        return Array.from(document.querySelectorAll('.product')).map(item => ({
            title: item.querySelector('h3 a')?.textContent?.trim(),
            price: item.querySelector('.price')?.textContent?.trim()
        }));
    });

    console.log(products);
    await browser.close();
})();
```







Here is what we got:

```
Status: 200
[
  { title: 'Box of Chocolate Candy', price: '24.99' },
  { title: 'Dark Red Energy Potion', price: '4.99' },
  { title: 'Teal Energy Potion', price: '4.99' },
  { title: 'Red Energy Potion', price: '4.99' },
  { title: 'Blue Energy Potion', price: '4.99' }
]
```



The above code runs the browser instance in the headless mode.

In the examples above, `playwright-extra` loads `puppeteer-extra-plugin-stealth` before launching Chromium.

The plugin is registered once, before the first `launch()`.

### TypeScript

Typescript used to be a transpile-only language where TS code would be converted to Javascript for NodeJS runtime. These days multiple runtimes don't require the transpilation step like [Bun](https://bun.sh/) or [Deno](https://deno.com/) and can run `.ts` files directly.

`node stealth-scraper.ts` worked on Node.js 26.12.

`playwright-extra` already ships its type declarations.

We renamed the ESM file to `stealth-scraper.ts`, set `"type": "module"` in `package.json` and installed `typescript` and `@types/node`.

Then, we used this `tsconfig.json`:

json

```json
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "strict": true,
    "types": ["node"],
    "skipLibCheck": true,
    "noEmit": true
  },
  "include": ["stealth-scraper.ts"]
}
```



The script compiled with no errors on TypeScript 7.0.2.

With `skipLibCheck` set to `false` we got 6 errors in the packages' declaration files and none in our script.

The errors are a `connectOverCDP` type mismatch in `playwright-extra` and missing `puppeteer` types in the plugin.

For more details about Playwright, refer to our previous article.

[Web Scraping with Playwright and JavaScriptLearn about Playwright - a browser automation toolkit for server side Javascript like NodeJS, Deno or Bun.](https://scrapfly.io/blog/posts/web-scraping-with-playwright-and-javascript)

So, we have both stacks running. But do both packages patch the same things? Let's take a look.



Scrapfly

#### Need to bypass anti-bot protection?

Scrapfly's Unblocker handles Cloudflare, DataDome, and more — automatically.

[Try Free →](https://scrapfly.io/register)## What Do the Playwright Stealth Evasion Modules Patch by Default?

Javascript exposes a colossal amount of information about the client and taming all of it to perfection would take thousands of hours of work.

That being said, not all information is equal, and we can plug the biggest holes quite confidently!

Not every leak is treated in a binary fashion (either you're a robot or not) but some definitely are.

Anti bot protection systems want to avoid false positives, and the web-space is diverse enough to provide some breathing room. That being said, plugging the biggest leaks is vital for any web scrapers that tries to access protected websites.

That being said, we have our tools, and we have to start somewhere. Let's take a look at some well known leak types and leaks and how can we plug them.

For this, good starting point is exploring [puppeteer-stealth](https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin-stealth) plugin which while dated and inaccurate at places, still contains a lot of important techniques and strategies we can learn from.

Python 2.0.3 applies 16 of its 18 scripts. `chrome_runtime=True` makes 17.

```
chrome_app
chrome_csi
chrome_hairline
chrome_load_times
iframe_content_window
media_codecs
navigator_languages
navigator_permissions
navigator_platform
navigator_plugins
navigator_user_agent
navigator_user_agent_data
navigator_vendor
navigator_webdriver
error_prototype
webgl_vendor
```



`navigator_user_agent_data` was added in Python 2.0.3.

The Node.js plugin applies these 16, and `navigator.vendor` stays off.

```
chrome.app
chrome.csi
chrome.loadTimes
chrome.runtime
defaultArgs
iframe.contentWindow
media.codecs
navigator.hardwareConcurrency
navigator.languages
navigator.permissions
navigator.plugins
navigator.webdriver
sourceurl
user-agent-override
webgl.vendor
window.outerdimensions
```



So, when using a headless browser for web scraping we want to ensure that we mimic the headful browser for these values.

```
Python hardwareConcurrency: 8
Node plugin hardwareConcurrency: 4
```



The Python script `navigator_hardware_concurrency` is never applied.

The knowledge of fingerprint leaking is a valuable trade secret for people working in the industry, so there's very little incentive to have the best solutions available publicly.

Python also applies `error_prototype` and `chrome_hairline`, and rewrites launch flags only in the context manager. Node applies `chrome.runtime`, `sourceurl`, `window.outerdimensions` and `defaultArgs`.

Playwright's `user_agent` context option changes both the HTTP User-Agent header and `navigator.userAgent`; check Client Hints and platform values separately.

`sec_ch_ua` is Python header code, not a script. `len(list(stealth.enabled_scripts))` returned 4.

### Customizing Modules

In Python, we can enable `chrome_runtime` through a keyword argument:

python

```python
stealth = Stealth(
    chrome_runtime=True,
    navigator_languages_override=("en-US", "en"),
    webgl_vendor_override="Intel Inc.",
)
```



This `stealth` object replaces `Stealth()` from the earlier code.

All we have to do is list the evasions in `enabledEvasions`:

javascript

```javascript
const stealth = StealthPlugin({
    enabledEvasions: new Set([
        'chrome.app',
        'chrome.csi',
        'chrome.loadTimes',
        'chrome.runtime',
        'defaultArgs',
        'iframe.contentWindow',
        'media.codecs',
        'navigator.hardwareConcurrency',
        'navigator.languages',
        'navigator.permissions',
        'navigator.plugins',
        'navigator.webdriver',
        'sourceurl',
        'user-agent-override',
        'webgl.vendor',
        'window.outerdimensions', // remove a line to turn that evasion off
    ]),
});
chromium.use(stealth);
```



For further details on JavaScript fingerprinting, refer to our [Puppeteer Stealth guide](https://scrapfly.io/blog/posts/puppeteer-stealth-complete-guide).

Now that we know what these packages patch, let's take a look at how we can test them.



## How Do You Test Whether Playwright Stealth Is Working?

There are many online tools that can analyze a web browser for the most common leaks and fingerprint values:

- [bot.sannysoft.com](https://bot.sannysoft.com/)
- [antoinevastel.com/bots](https://antoinevastel.com/bots/)
- [headless-cat-n-mouse](https://github.com/paulirish/headless-cat-n-mouse)
- [CreepJS](https://abrahamjuliot.github.io/creepjs/)

It's worth noting that none of these tools are perfect and since the web browser environment is constantly evolving and changing with every new browser release we should confirm all of this data ourselves.

For this, let's use a small test script that will let us compare our automated browsers against the real ones:

python

```python
import asyncio
import json

from playwright.async_api import async_playwright
from playwright_stealth import Stealth


async def main():
    stealth = True
    if stealth:
        manager = Stealth().use_async(async_playwright())
        shot = "stealth_on.png"
    else:
        manager = async_playwright()
        shot = "stealth_off.png"

    async with manager as playwright:
        # launch playwright chromium browser
        browser = await playwright.chromium.launch(headless=True)

        # new browser session with the default settings
        context = await browser.new_context()

        # new browser tab
        page = await context.new_page()

        # request the target page url
        await page.goto("https://httpbin.dev/headers")
        headers = json.loads(await page.inner_text("body"))["headers"]
        data = await page.evaluate(
            """() => ({
                webdriver: navigator.webdriver,
                plugins: navigator.plugins.length,
                languages: navigator.languages,
                platform: navigator.platform,
                userAgent: navigator.userAgent,
                uaDataPlatform: navigator.userAgentData && navigator.userAgentData.platform,
                brands: navigator.userAgentData && navigator.userAgentData.brands.map(b => b.brand + " " + b.version),
                cores: navigator.hardwareConcurrency
            })"""
        )
        print("webdriver:", data["webdriver"])
        print("plugins:", data["plugins"])
        print("languages:", data["languages"])
        print("platform:", data["platform"])
        print("userAgent:", data["userAgent"])
        print("uaDataPlatform:", data["uaDataPlatform"])
        print("brands:", data["brands"])
        print("cores:", data["cores"])
        print("User-Agent header:", headers["User-Agent"][0])
        print("Sec-Ch-Ua header:", headers["Sec-Ch-Ua"][0])

        await page.goto("https://scrapfly.io/web-scraping-tools/browser-fingerprint")
        await page.wait_for_timeout(3000)
        await page.screenshot(path=shot, full_page=True)

        # close the browser
        await browser.close()


asyncio.run(main())
```



Here is what we got:

```
webdriver: False
plugins: 3
languages: ['en-US', 'en']
platform: Win32
userAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/156.0.8078.4 Safari/537.36
uaDataPlatform: Linux
brands: ['Not:A-Brand 8', 'Chromium 156', 'Google Chrome 156']
cores: 8
User-Agent header: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/156.0.8078.4 Safari/537.36
Sec-Ch-Ua header: "Chromium";v="156", "Chrome";v="156", "Not/A)Brand";v="8"
```



The same checks with no stealth and with the Node plugin:

```
no stealth
webdriver: true
plugins: 0
languages: en-US
User-Agent header: HeadlessChrome/156, Linux
navigator.platform: Linux x86_64
userAgentData.platform: Linux
hardwareConcurrency: 8

Python use_async
webdriver: false
plugins: 3
languages: en-US, en
User-Agent header: Chrome/156, Linux
navigator.platform: Win32
userAgentData.platform: Linux
hardwareConcurrency: 8

Node plugin
webdriver: false
plugins: 3
languages: en-US, en
User-Agent header: Chrome/156, Windows
navigator.platform: Win32
userAgentData.platform: Windows
hardwareConcurrency: 4
```



When it comes to javascript we want to ensure that **header values match the browser capabilities**.

So if we're using a Windows based User-Agent header on a Linux based web scraper, we need to modify the javascript namespaces (like `navigator.platform` etc) to reflect the correct operating system.

Python kept a Linux User-Agent and set `navigator.platform` to `Win32`.

python

```python
Stealth(navigator_platform_override="Linux x86_64").use_async(async_playwright())
```



With that argument, the User-Agent, `navigator.platform` and `userAgentData.platform` all said Linux.

We also want to use user agent string **with the same browser version we are using** as every browser version has unique features which can be determined from the javascript environment.

The Windows run already agreed, and all three values said Windows. On Linux, the Node plugin reported Windows for all three, from `maskLinux`, which is on by default.

```
Chromium 156 Sec-CH-UA: "Not:A-Brand";v="8"
Node plugin Sec-CH-UA: " Not A;Brand";v="99"
Python userAgentData.brands: Not:A-Brand 8, Google Chrome 156
```



The Node plugin writes version 99 for that brand. Python picked a new placeholder on each run, and the JavaScript brands stayed on `Not:A-Brand 8`.

So, when using a headless browser for web scraping we want to ensure that we mimic the headful browser for these values.

```
headless shell, stealth on: 3 plugins
channel="chromium", no stealth: 5 plugins
```



The count follows the browser we launched.

Here's the Navigator Properties panel with no stealth:



And here's the same panel with Python stealth:



Above, we see that `WEBDRIVER`, `PLUGINS` and `LANGUAGES` changed and `PLATFORM` became `Win32`. `HARDWARECONCURRENCY` stayed on 8.

Note that properties marked in red are highly unique, so **a red row doesn't mean the browser was detected**.

A clean result only means the fields we checked agree with each other.

For more, see our [browser fingerprint testing tools](https://scrapfly.io/blog/posts/best-browser-fingerprint-testing-tools).

But what about when all of these checks pass and the website still blocks us? Let's take a look at what stealth packages can't reach.



## Why Does Playwright Still Get Blocked With Stealth Enabled?

The [playwright-stealth readme](https://github.com/Mattwmaster58/playwright_stealth) says don't expect this to bypass anything but the simplest of bot detection methods, and calls the package a proof-of-concept starting point.

To patch these leaks in our browser automation tools we can take advantage of page initiation script functionality, which is how playwright stealth loads before the page's own scripts.

Browsers are very complex software suites and to deal with this complexity every browser can be customized via launch flags, which Python does in the context manager and Node does in `defaultArgs` and the user-agent override.

There are multiple factors that lead to web scraping blocking including headers, IP addresses, security handshakes and javascript execution. To scrape without getting blocked, you must pay attention to these details.

We read the `playwright-stealth` 2.0.3 source, and besides the launch flags it only patches the headers and the javascript.

When it comes to javascript we want to ensure that **header values match the browser capabilities**. So, let's check a few of these pairs on a stealth browser:

python

```python
import asyncio
import json

from playwright.async_api import async_playwright
from playwright_stealth import Stealth


async def main():
    async with Stealth().use_async(async_playwright()) as playwright:
        browser = await playwright.chromium.launch(headless=True)
        page = await browser.new_page()
        await page.goto("https://httpbin.dev/headers")
        headers = json.loads(await page.inner_text("body"))["headers"]
        data = await page.evaluate("""() => ({
            platform: navigator.platform,
            uaDataPlatform: navigator.userAgentData.platform,
            brands: navigator.userAgentData.brands.map(b => b.brand + " " + b.version).join(", ")
        })""")
        print("User-Agent header:", headers["User-Agent"][0])
        print("navigator.platform:", data["platform"])
        print("userAgentData.platform:", data["uaDataPlatform"])
        print("Sec-Ch-Ua header:", headers["Sec-Ch-Ua"][0])
        print("userAgentData.brands:", data["brands"])
        await browser.close()


asyncio.run(main())
```



Here is what we got:

```
User-Agent header: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/156.0.8078.4 Safari/537.36
navigator.platform: Win32
userAgentData.platform: Linux
Sec-Ch-Ua header: "Chromium";v="156", "Not;A:Brand";v="99", "Chrome";v="156"
userAgentData.brands: Not:A-Brand 8, Chromium 156, Google Chrome 156
```



The User-Agent says Linux while `navigator.platform` says `Win32`, and the header brands don't match `userAgentData.brands`.

Here are the same two lines from a second run:

```
Sec-Ch-Ua header: "Chrome";v="156", "Not(A?Brand";v="8", "Chromium";v="156"
userAgentData.brands: Not:A-Brand 8, Chromium 156, Google Chrome 156
```



The header got a new placeholder brand, and javascript kept `Not:A-Brand 8`.

`navigator_platform_override` fixed the platform pair in our testing section. The Node plugin has its own brand mismatch, as it sends `" Not A;Brand";v="99"` while Chromium 156 sends `"Not:A-Brand";v="8"`.

With `launch_persistent_context()`, `navigator.webdriver` stayed `true`, as the 2.0.3 wrapper doesn't hook that method.

Detection can come from how Playwright drives Chromium over CDP. For further details, refer to our [CDP detection guide](https://scrapfly.io/blog/posts/chrome-cdp-stealth-browser-automation-detection-explained).

Patchright works on that layer, as it patches the Playwright driver and not the Chromium source. Its README also says it only patches Chromium-based browsers, so Firefox and WebKit aren't supported.

One of the sneakiest and least known ways of detecting and fingerprinting web scraper traffic is Transport Layer Security (TLS) analysis.

Every HTTPS connection has to establish a secure handshake, and the way this handshake is performed can lead to fingerprinting and web scraping blocking.

IP address itself provides very little information about the identity of its owner. So, IP meta-information databases are used to provide more context about connecting clients.

Stealth packages don't change the [TLS handshake](https://scrapfly.io/blog/posts/ja3-ja4-tls-fingerprinting-guide-to-detection-and-evasion) or our IP address.

For more see our [Cloudflare guide](https://scrapfly.io/blog/posts/how-to-bypass-cloudflare-anti-scraping) and [stealth browsers](https://scrapfly.io/blog/posts/best-stealth-browsers), as we didn't test Cloudflare for this article.

[5 Tools to Scrape Without Blocking and How it All WorksTutorial on how to avoid web scraper blocking. What is javascript and TLS (JA3) fingerprinting and what role request headers play in blocking.](https://scrapfly.io/blog/posts/how-to-scrape-without-getting-blocked-tutorial)

If all that seems like too much trouble let Scrapfly handle it for you!



## How Do You Run Playwright Scripts on Scrapfly Cloud Browser?

Local headless browsers are difficult to scale, and managing complex software like a web browser in each scraping process can be very challenging, slow and error prone.

As a response to that a collection of web browsers can be **managed and deployed on cloud environments** and serve each web scraper as a service. These are called cloud browsers.

Primary goal of cloud browsers is to simplify and scale up web browser automation tasks like testing and scraping.

Self-hosting cloud browsers can be difficult, and managed cloud browser services handle the infrastructure and scaling for you.

Web scraping focused cloud browser services like [ScrapFly](https://scrapfly.io/products/cloud-browser-api) also fortify the headless browser instances to bypass scraper blocking and increase browser rendering speeds through [Scrapium](https://scrapfly.io/scrapium) patches at the Chromium source making it a much easier solution for smaller teams.

Cloud browsers are very powerful tools in web scraping yet not all scraping problems can be solved using these tools and this is where Scrapfly can lend a hand!

Here's how to scrape with cloud browsers using ScrapFly, with the key read from the `SCRAPFLY_KEY` environment variable.

python

```python
import asyncio
import os

from playwright.async_api import async_playwright

API_KEY = os.environ["SCRAPFLY_KEY"]
WS_URL = (
    "wss://browser.scrapfly.io"
    f"?api_key={API_KEY}&proxy_pool=residential&os=windows"
)


async def main():
    async with async_playwright() as playwright:
        browser = await playwright.chromium.connect_over_cdp(WS_URL)
        try:
            context = browser.contexts[0]
            page = context.pages[0] if context.pages else await context.new_page()
            await page.goto("https://web-scraping.dev/products")
            print(await page.title())
        finally:
            await browser.close()


asyncio.run(main())
```



The above code represents the core concept behind cloud browser scraping and replaces `chromium.launch()` with `chromium.connect_over_cdp()` pointing at `wss://browser.scrapfly.io`.

The browser runs on Scrapfly, and our script only sends it Playwright commands over that WebSocket. So, pages load through Scrapfly's proxy network and report the session's fingerprint, whichever machine runs our script.

I checked the local side with no Playwright browsers installed. `chromium.launch()` failed with `Executable doesn't exist`, while `connect_over_cdp()` to an already running Chromium loaded the web-scraping.dev product page, so this script doesn't need `playwright install chromium`.

The connection URL sets up that remote browser. `proxy_pool=residential` picks the residential proxy network, and `os=windows` sets the operating system fingerprint the session reports.

When web scraping we want to avoid IPs with metadata that might indicate non-human connections (like IPs that are owned by a datacenter). Instead, we should aim for residential or mobile IPs which make connection appear much more human.

Scraper controlled browsers often contain extra javascript environment information that indicate the browser is running without GUI elements (aka headless) or run on uncommon operating systems (e.g. Linux)

Apart from `connect_over_cdp()` and `browser.contexts[0]`, the rest is regular Playwright code.

An open session keeps running and billing, so we close the browser in `finally`.

The session only has one context, and `browser.new_page()` fails with this message:

```
Cloud Browser runs one browser context per session, so browser.newContext() and browser.newPage() cannot open a page: use browser.contexts()[0].newPage() (Python: browser.contexts[0].new_page())
```



For further details on the available features and capabilities, refer to the [Cloud Browser Playwright docs](https://scrapfly.io/docs/cloud-browser-api/playwright).

For example, here is how to use [ScrapFly](https://scrapfly.io/products/web-scraping-api) to **scrape dynamic pages without getting blocked** when the page has no clicks or forms.

All we have to do is enable the [Unblocker (previously ASP)](https://scrapfly.io/products/unblocker) with `unblocker=True` and `render_js=True`.

Finally, we went through a step-by-step guide on connecting Playwright to a cloud browser for web scraping.



## FAQ

Does playwright-stealth still work in 2026?Yes, but only for basic fingerprint checks. Both stacks installed and ran on Playwright 1.64.1 in November 2026 and changed `navigator.webdriver` to false. Python 2.0.3 was released on April 4, 2026 and the Node.js packages on March 1, 2023.

The Python README says not to expect it to bypass anything but the simplest bot detection.







Does Playwright stealth work with Firefox or WebKit?We've only tested this guide's setups on Chromium, and both packages target Chromium. The Python package hooks Chromium, Firefox and WebKit launches, but its launch flag changes only apply to Chromium and several scripts patch Chrome-only APIs like `window.chrome`.

The [playwright-extra README](https://github.com/berstend/puppeteer-extra/tree/master/packages/playwright-extra) also says the stealth plugin is optimized for Chromium-based browsers.







Can Playwright stealth solve CAPTCHAs or Turnstile challenges?No, none of the default evasions in either package can solve a challenge, as these evasions only change what the page reads before its scripts run.

If a challenge still appears with stealth on, it won't tell us the cause. So, we have to go through the failure modes listed earlier.









## Summary: Which Playwright Stealth Setup Should You Use?

In this article, we explained how to use Playwright stealth to patch headless browser leaks. We went through a step-by-step guide on setting up Python and Node.js, fixing the import error and testing the results.

We have seen how to use `playwright-stealth` 2.0.3 in Python through the context manager with `navigator_platform_override`, and `playwright-extra` with the stealth plugin in Node.js. We can also rerun the before and after script whenever the browser or package version changes.

All that being said, JavaScript fingerprinting is one of the biggest and most complex subjects in web scraping, and it constantly evolves with each web browser iteration.

However, just plugging holes is not enough to scrape well protected targets at scale, as websites can still check the automation protocol, session state, the IP address and browsing behavior.

For an easier way to handle web scraper blocking with your existing Playwright code, check out Scrapfly [Cloud Browser](https://scrapfly.io/products/cloud-browser-api) for free!

Legal Disclaimer and PrecautionsThis tutorial covers popular web scraping techniques for education. Interacting with public servers requires diligence and respect:

- Do not scrape at rates that could damage the website.
- Do not scrape data that's not available publicly.
- Do not store PII of EU citizens protected by GDPR.
- Do not repurpose *entire* public datasets which can be illegal in some countries.

Scrapfly does not offer legal advice but these are good general rules to follow. For more you should consult a lawyer.



 

   [  Add as a preferred source ](https://google.com/preferences/source?q=scrapfly.io) Table of Contents















 

  Table of Contents

- [Key Takeaways](#key-takeaways)
- [How Do Websites Detect Headless Playwright?](#how-do-websites-detect-headless-playwright)
- [What Is Playwright Stealth, and Which Package Do You Need?](#what-is-playwright-stealth-and-which-package-do-you-need)
- [How Do You Set Up playwright-stealth in Python?](#how-do-you-set-up-playwright-stealth-in-python)
- [Setup](#setup)
- [Async Example](#async-example)
- [Sync Example](#sync-example)
- [Applying Stealth Manually](#applying-stealth-manually)
- [How Do You Fix "cannot import name 'stealth\_sync' from 'playwright\_stealth'"?](#how-do-you-fix-cannot-import-name-stealth-sync-from-playwright-stealth)
- [How Do You Use Playwright Stealth in Node.js and TypeScript?](#how-do-you-use-playwright-stealth-in-node-js-and-typescript)
- [Setup](#setup)
- [ESM and CommonJS](#esm-and-commonjs)
- [TypeScript](#typescript)
- [What Do the Playwright Stealth Evasion Modules Patch by Default?](#what-do-the-playwright-stealth-evasion-modules-patch-by-default)
- [Customizing Modules](#customizing-modules)
- [How Do You Test Whether Playwright Stealth Is Working?](#how-do-you-test-whether-playwright-stealth-is-working)
- [Why Does Playwright Still Get Blocked With Stealth Enabled?](#why-does-playwright-still-get-blocked-with-stealth-enabled)
- [How Do You Run Playwright Scripts on Scrapfly Cloud Browser?](#how-do-you-run-playwright-scripts-on-scrapfly-cloud-browser)
- [FAQ](#faq)
- [Summary: Which Playwright Stealth Setup Should You Use?](#summary-which-playwright-stealth-setup-should-you-use)
 
    Join the Newsletter  Get monthly web scraping insights 

 

  



Scale Your Web Scraping

Anti-bot bypass, browser rendering, and rotating proxies, all in one API. Start with 1,000 free credits.

  No credit card required  1,000 free API credits  Anti-bot bypass included 

 [Start Free](https://scrapfly.io/register) [View Docs](https://scrapfly.io/docs/onboarding) 

 Not ready? Get our newsletter instead. 

 

 ## Related Articles

 [     

 blocking nodejs 

### Puppeteer Stealth: Complete Guide to Avoiding Detection

Complete guide to puppeteer-extra-plugin-stealth for avoiding bot detection. Learn how detection works, configure stealt...

 

 ](https://scrapfly.io/blog/posts/puppeteer-stealth-complete-guide) [     

 blocking nodejs 

### Web Scraping With Node-Unblocker

Tutorial on using Node-Unblocker - a nodejs library - to avoid blocking while web scraping and using it to optimize web ...

 

 ](https://scrapfly.io/blog/posts/web-scraping-with-node-unblocker) [     

 blocking 

### How to Bypass Cloudflare When Web Scraping in 2026

Cloudflare offers one of the most popular anti scraping service, so in this article we'll take a look how it works and h...

 

 ](https://scrapfly.io/blog/posts/how-to-bypass-cloudflare-anti-scraping) 

  



   



 Bypass anti-bot protection automatically, **1,000 free credits** [Start Free](https://scrapfly.io/register)