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:
- Using browser-cookie3 to decrypt Chrome's cookie values via the macOS Keychain.
- Reading Chrome's SQLite Cookies database directly to extract
httpOnly,sameSite,secure, and precise expiry metadata. - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters