---
title: Convert Puppeteer tests to Playwright tests
description: Puppeteer to Playwright script converter. Convert all your existing Puppeteer
  test scripts to Playwright test scripts with this online free tool.
source_url:
  html: https://testingbot.com/free-online-tools/puppeteer-to-playwright-converter
  md: https://testingbot.com/free-online-tools/puppeteer-to-playwright-converter.md
---

[Tools](https://testingbot.com/free-online-tools)Converters

# Puppeteer to Playwright

Convert test scripts automatically

This free tool will automatically convert any Puppeteer script or test to a Playwright script.

 Enter Puppeteer code:  

Converted Playwright Code:

This online tool is built for developers and QA. It will replace existing Puppeteer syntax with Playwright syntax.

You can quickly convert your existing Puppeteer scripts to Playwright, without having to manually do the conversion yourself.

## Why should I migrate from Puppeteer scripts to Playwright scripts?

There are multiple reasons why you would want to start using Playwright. One reason is that Playwright runs on non-chromium based browsers, such as Firefox. Another reason might be that you want to use a library or specific Playwright extension.

While both are very similar in the features they offer and even the syntax, there are some subtle differences. Puppeteer uses the CDP protocol to instrument browsers, whereas Playwright uses its own, custom protocol.

## How can I manually convert Puppeteer code to Playwright code?

### Changing the required package

First, you need to change the require of the Puppeteer package to Playwright. You'll need to replace the code below.

```javascript
const puppeteer = require('puppeteer'); (async () => { const
                browser = await puppeteer.launch(); const page = await
                browser.newPage();
```

With a new require, requiring the Playwright package.

```javascript
const { chromium } = require('playwright'); (async () => { const
                browser = await chromium.launch(); const page = await
                browser.newPage();
```

### Cookies

Puppeteer handles cookies at the page level, whereas with Playwright you need to manipulate cookies at the `BrowserContext` level. This means that these Puppeteer cookie functions:

- `page.cookies([...urls])`
- `page.deleteCookie(...cookies)`
- `page.setCookie(...cookies)`

will become these functions with Playwright:

- `browserContext.cookies([urls])`
- `browserContext.clearCookies()`
- `browserContext.addCookies(cookies)`

### Viewport

Puppeteer's `page.setViewport` becomes `page.setViewportSize` in Playwright.

### All Tools

#### Accessibility

- [Color Contrast Checker](https://testingbot.com/free-online-tools/color-contrast-checker)

#### Calculator

- [Test Effort Estimator](https://testingbot.com/free-online-tools/test-effort-estimator)
- [Test Coverage Calculator](https://testingbot.com/free-online-tools/test-coverage-calculator)

#### Converter

- [Unix Timestamp Converter](https://testingbot.com/free-online-tools/unix-timestamp-converter)

#### Formatter

- [JSON Prettifier](https://testingbot.com/free-online-tools/json-prettify)
- [HTML Escaper](https://testingbot.com/free-online-tools/html-escape)
- [XML Prettifier](https://testingbot.com/free-online-tools/xml-prettify)
- [Remove Whitespace](https://testingbot.com/free-online-tools/remove-all-whitespace)
- [Text to One Line](https://testingbot.com/free-online-tools/text-to-one-line)
- [PX to REM Converter](https://testingbot.com/free-online-tools/px-to-rem-converter)
- [CSS Prettifier](https://testingbot.com/free-online-tools/css-prettify)

#### Generator

- [Random Avatar Generator](https://testingbot.com/free-online-tools/free-avatar-generator)
- [Placeholder Image Generator](https://testingbot.com/free-online-tools/placeholder-image-generator)
- [Random Address Generator](https://testingbot.com/free-online-tools/random-address-generator)
- [Credit Card Generator](https://testingbot.com/free-online-tools/credit-card-number-generator)
- [Random Number Generator](https://testingbot.com/free-online-tools/random-number-generator)
- [JWT Parser](https://testingbot.com/free-online-tools/jwt-parser)
- [Fake Person Generator](https://testingbot.com/free-online-tools/fake-person-generator)
- [Hash Text](https://testingbot.com/free-online-tools/hash-text)
- [Lorem Ipsum Generator](https://testingbot.com/free-online-tools/lorem-ipsum-generator)
- [Random IP Generator](https://testingbot.com/free-online-tools/random-ip-generator)
- [Random GUID Generator](https://testingbot.com/free-online-tools/random-guid-generator)
- [Character Count](https://testingbot.com/free-online-tools/character-count)
- [ASCII to Binary](https://testingbot.com/free-online-tools/ascii-to-binary)
- [Random Color Generator](https://testingbot.com/free-online-tools/random-color-generator)
- [Open Graph Meta Generator](https://testingbot.com/free-online-tools/og-meta-generator)
- [QR Code Generator](https://testingbot.com/free-online-tools/qr-code-generator)
- [Device Information](https://testingbot.com/free-online-tools/device-information)
- [User Agent Parser](https://testingbot.com/free-online-tools/user-agent-parser)
- [Image Extractor](https://testingbot.com/free-online-tools/image-extractor)
- [Test Plan Generator](https://testingbot.com/free-online-tools/test-plan-generator)

#### Network

- [CORS Tester](https://testingbot.com/free-online-tools/cors-tester)
- [My GPS Location](https://testingbot.com/free-online-tools/my-gps-location)
- [What's My IP Address](https://testingbot.com/free-online-tools/whats-my-ip-address)
- [IP Subnet Calculator](https://testingbot.com/free-online-tools/ip-subnet-calculator)

#### Scheduler

- [Cron Expression Generator](https://testingbot.com/free-online-tools/cron-expression-generator)

#### Speed

- [Critical CSS Generator](https://testingbot.com/free-online-tools/critical-css-generator)

#### Testing

- [XPath & CSS Selector Tester](https://testingbot.com/free-online-tools/xpath-css-selector-tester)

[View all tools](https://testingbot.com/free-online-tools)
