Skip to main content

Export Chrome cookies to Playwright storage state format (macOS)

Project description

chrome-cookies-to-playwright

Export your macOS Chrome cookies to Playwright storage state format — with full httpOnly, sameSite, and expiry metadata.

Quick Start

# Zero-install (requires Python 3.9+)
uvx chrome-cookies-to-playwright

# Or install globally
pip install chrome-cookies-to-playwright
chrome-cookies-to-playwright

What It Does

Playwright's built-in cookie APIs cannot access httpOnly or sameSite flags from a real browser profile. This tool works around that by:

  1. Using browser-cookie3 to decrypt Chrome's cookie values via the macOS Keychain.
  2. Reading Chrome's SQLite Cookies database directly to extract httpOnly, sameSite, secure, and precise expiry metadata.
  3. Joining the two data sources into a single Playwright storage state JSON file that you can load with browserContext.addCookies() or the Playwright CLI.

The result is a complete, accurate cookie export that preserves all the metadata Playwright needs.

Usage

chrome-cookies-to-playwright [--output FILE] [--profile NAME] [--domain FILTER]
Option Description
--output, -o Output file path (default: /tmp/chrome-cookies-state.json)
--profile, -p Chrome profile directory name (default: Default)
--domain, -d Only export cookies whose domain contains this string

Examples

# Export all cookies
chrome-cookies-to-playwright

# Export only GitHub cookies
chrome-cookies-to-playwright --domain github.com

# Use a specific Chrome profile and custom output path
chrome-cookies-to-playwright --profile "Profile 1" --output ./cookies.json

Using the output with Playwright

# Python
context = browser.new_context(storage_state="/tmp/chrome-cookies-state.json")
// JavaScript
const context = await browser.newContext({
  storageState: '/tmp/chrome-cookies-state.json'
});

How It Works

Chrome stores cookies in an SQLite database at:

~/Library/Application Support/Google/Chrome/<Profile>/Cookies

Cookie values are encrypted with a key stored in the macOS Keychain. browser-cookie3 handles this decryption. However, it doesn't expose httpOnly or sameSite metadata.

This tool reads the SQLite database directly to get those fields, then joins the results with the decrypted values to produce a complete Playwright-compatible storage state.

Chrome timestamp conversion

Chrome uses a custom epoch (1601-01-01 00:00:00 UTC) with microsecond precision. The tool converts these to Unix timestamps that Playwright expects.

Requirements

  • macOS (relies on Chrome's Keychain-based cookie encryption)
  • Google Chrome installed
  • Full Disk Access permission for your terminal (System Settings → Privacy & Security → Full Disk Access)
  • Python 3.9+

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chrome_cookies_to_playwright-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chrome_cookies_to_playwright-0.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file chrome_cookies_to_playwright-0.1.0.tar.gz.

File metadata

File hashes

Hashes for chrome_cookies_to_playwright-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b134e9baac4ca8e3624befdbea8dbbd2cbfcdbd5cd9b86f24943df05133f679c
MD5 d0406facef07fc481ec2efc11cd79aa5
BLAKE2b-256 58b8122ea5f95189a54f31459b883b83b82fb93060b418d8ee14bbe1678d9833

See more details on using hashes here.

File details

Details for the file chrome_cookies_to_playwright-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for chrome_cookies_to_playwright-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a964dff15e294ac6138ca6a443fec835b375bef938a039023cc76b07b20d0d23
MD5 8d3c498fa0eec0ee620e8b60f8ea41e5
BLAKE2b-256 c9b659a71ec1a24072fe531e816b6a5df3f6523ac8c5cdb2aa78619a0fe76e00

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page