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.1.tar.gz (5.6 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.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for chrome_cookies_to_playwright-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e3a77ebf019619f605edb66152ce8b58e0e91cbb59bf5e82d4fd5f503bbf69d2
MD5 be16dae3c6369966cb14d2a2f3f27042
BLAKE2b-256 b68078c8f31ac227473d22f163da981e9f2f101402943b367a9bd9c6f3e2bc66

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chrome_cookies_to_playwright-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21787cc1ecb14ed2ec7e1829d44e115b5b06355d2ea3a27f2a6ed4593c333d99
MD5 7c3ac2bc8a432b85516eb7777688fd6c
BLAKE2b-256 0abe092a0fbc04a940e793e63095f5bce026e21792c01f268ccf48be972271ca

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