Skip to main content

Stop hand-editing cookies.txt — convert Netscape, Playwright, Selenium, and Set-Cookie formats in one CLI.

Project description

cookie-jar-bridge

Python 3.10+ | MLX optional · Compatibility

Convert and validate browser cookies across Netscape (cookies.txt), Playwright storage state JSON, Selenium cookie dict lists, and raw HTTP Set-Cookie headers.

Pure Python — no browser required for convert, validate, or merge.

Problem

Cookie exports arrive in incompatible shapes:

  • curl / browser extensions → Netscape cookies.txt
  • Playwright → storage_state.json with cookies + origins
  • Selenium → list of {"name", "value", "domain", ...} dicts
  • HTTP traces → Set-Cookie: header lines

Teams waste time hand-editing tab-separated files or writing one-off scripts. cookie-bridge normalizes to a canonical model and writes any supported output format.

pip install

pip install cookie-jar-bridge

MLX profile import (unlock + Launcher API):

pip install cookie-jar-bridge[mlx]

Quick start

# Playwright storage state -> Netscape (for curl, wget, legacy tools)
cookie-bridge convert state.json --to netscape -o cookies.txt

# Netscape -> Playwright storage state
cookie-bridge convert cookies.txt --to playwright-json -o state.json

# Validate a jar before use
cookie-bridge validate cookies.txt

# Merge exports from a folder (later files win on duplicates)
cookie-bridge merge ./exports/ -o merged.txt
from cookie_jar_bridge import load_cookies, convert_cookies

cookies = load_cookies(open("cookies.txt").read())
open("state.json", "w").write(convert_cookies(cookies, "playwright-json"))

CLI

Command Description
cookie-bridge convert INPUT --to FORMAT -o OUT Convert between formats
cookie-bridge validate INPUT Structural + semantic checks (--host for domain match)
cookie-bridge stats INPUT Domain counts + expiry histogram
cookie-bridge merge DIR/ -o OUT Merge .txt/.json cookie files
cookie-bridge mlx-import --profile-id UUID --input FILE MLX unlock + import ([mlx])

Format conversion matrix

From ↓ / To → Netscape (curl -b) Playwright JSON Selenium JSON Set-Cookie lines
Netscape convert --to playwright-json convert --to selenium-json convert --to set-cookie
Playwright convert --to netscape via Netscape or direct JSON convert --to set-cookie
Selenium convert --to netscape convert --to playwright-json convert --to set-cookie
Set-Cookie convert --to netscape convert --to playwright-json convert --to selenium-json
--to / auto-detect Description
netscape Tab-separated cookies.txt (curl-compatible)
playwright-json Playwright storage_state object
selenium-json JSON array of Selenium cookie dicts
set-cookie Set-Cookie: header lines

Use --from FORMAT to override auto-detection.

validate checks expired cookies, Netscape subdomain/domain flag mismatches, optional --host example.com, and httpOnly issues on secure session-like cookies.

Exit codes

Code Meaning
0 Success
1 Validation failed (validate) or --strict warnings
2 Runtime error

API

Symbol Description
load_cookies(text, fmt=None) Parse any supported format
detect_format(text) Auto-detect source format
convert_cookies(cookies, target) Serialize to target format
validate_text(text) Return ValidationReport
merge_directory(path) Merge files → list[Cookie]

MLX import ([mlx] extra)

Imports cookies into a Multilogin X profile:

  1. Unlock profile via Cloud API GET /profile/unlock?profile_ids=UUID
  2. Import via Launcher POST /api/v1/cookies/import
export MLX_TOKEN="your-bearer-token"
cookie-bridge mlx-import --profile-id PROFILE_UUID --input cookies.txt

Requires the Multilogin desktop agent running locally.

Limitations

  • No live browser sync — converts static files only; does not read Chrome SQLite or Firefox cookies.sqlite directly.
  • Domain inference — Set-Cookie lines without Domain= may produce cookies missing domain until you add it manually.
  • Merge scopemerge reads .txt, .json, .cookies in one directory; no recursive subfolders.
  • MLX import — Launcher must be running; encrypted profiles must unlock successfully before import.
  • Not a security audit — validation checks structure, not cookie secrecy or theft risk.

Production

Partner offers, eligibility, and disclosure: docs/AFFILIATE.md.

For production antidetect workflows, convert cookies to the format your stack expects, validate before import, then push to isolated profiles:

cookie-bridge convert export.json --to netscape -o clean.txt
cookie-bridge validate clean.txt --strict
cookie-bridge mlx-import --profile-id "$PROFILE_ID" --input clean.txt

Pair with playwright-cdp-probe to audit the session after import.

Guides

Monorepo playbooks (copy-paste commands, sample output, diagrams):

Guide Flow
Detection fail → MLX farm cdp-probecdp-connectfarm-runner mlx-pool
Competitor migration antidetect-importprofile-factory mlx-create
Proxy lane → profile pool proxy-laneprofile-factoryfarm-runner mlx-pool

FAQ: docs/FAQ.md — Netscape cookies, Playwright JSON, merge formats.

curl / requests: docs/CURL_RECIPES.md — Netscape → curl -b, Playwright state → requests.Session (5 copy-paste recipes).

Related tools

Tool Use with
playwright-cdp-probe — Score CDP/WebDriver exposure and fingerprint leaks cdp-connect-kit when probe fails
cookie-jar-bridge — Convert, validate, and merge cookies across formats session-bundle-kit for full session
proxy-lane-checker — Batch-check proxies for connectivity, geo, and DNSBL profile-yaml-factory
fingerprint-coherence — Lint fingerprints for cross-signal contradictions profile-yaml-factory before create
human-input-kit — Human-like mouse, scroll, and warmup replay automation-farm-runner
cdp-connect-kit — Playwright CDP connect; MLX start/stop helpers → all packages needing CDP
session-bundle-kit — Export/import cookies and storage as portable bundles cookie-jar-bridge
profile-yaml-factory — YAML blueprints → MLX profile/create payloads antidetect-importer after migration
antidetect-importer — Parse competitor exports and push to MLX profile-yaml-factory
automation-farm-runner — YAML job queue and MLX profile-pool runner cdp-connect-kit [mlx]

License

MIT


Production antidetect: Multilogin X · Code SAAS50 (-50% browser) · MIN50 (-50% cloud phone)
More scripts: @Multilogin_Scripts_Bot · Coupons

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

cookie_jar_bridge-0.2.0.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

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

cookie_jar_bridge-0.2.0-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

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