Skip to main content

cookie-jar-bridge

Netscape cookies.txt ↔ Playwright JSON — convert, validate, and merge browser cookies; MLX import optional.

PyPI version Python versions License: MIT

pip install cookie-jar-bridge
cookie-bridge validate cookies.txt

CLI: cookie-bridge · Python 3.10+ · optional [mlx] for Launcher helpers

Coupon hub: Verified MLX deals (SAAS50 browser / MIN50 cloud phone) — Multilogin promo codes. Core CLI works without a vendor account. Affiliate disclosure.

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.

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.

When imported cookies fail login (playbook)

Conversion succeeded but the site still asks you to sign in — usually context, not format.

Symptom Likely cause Fix
Valid jar, no session www vs apex domain validate --host example.com; re-export with correct domain
Worked once, then logout Expired expiry or session cookie cookie-bridge stats histogram; refresh export
Login on old IP only New fingerprint/proxy Match proxy-lane-checker + profile
MLX import ok, site fails IP/device challenge cdp-probe after import

Session import pipeline (fleet tail):

cookie-bridge merge ./exports/ -o merged.txt
cookie-bridge validate merged.txt --strict --host your-app.example
cookie-bridge convert merged.txt --to playwright-json -o state.json
cookie-bridge mlx-import --profile-id PROFILE_UUID --input merged.txt   # optional MLX
cdp-probe mlx --profile-id PROFILE_UUID --url https://your-app.example

Coupon hub: Multilogin promo codes — guides for SAAS50 / MIN50, pricing comparisons, and workflow playbooks.

See docs/CURL_RECIPES.md for curl -b and requests without a browser.

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

Convert → validate --strict → import into isolated profiles (Playwright storage_state or MLX mlx-import). Cookies restore stored credentials — they do not fix fingerprint or IP drift alone.

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

Partner note (affiliate): Multi-account persistence usually needs cookies in isolated Multilogin X profiles with matched proxy/fingerprint — not a shared daily browser. Eligible new browser purchases may accept code SAAS50 at multilogin.com — verify terms before checkout. Convert/validate/merge need no MLX. Full disclosure: docs/AFFILIATE.md. Deals hub: anti-detect.github.io. Coupon details only via cookie-bridge --show-deal (never printed by default).

FAQ: docs/FAQ.md — Netscape cookies.txt, Playwright storage_state, curl import.

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

Related tools (on PyPI)

Package CLI Role
playwright-cdp-probe cdp-probe CDP / WebDriver exposure score
cookie-jar-bridge cookie-bridge Netscape ↔ Playwright cookies
proxy-lane-checker proxy-lane Proxy TCP / HTTP / geo / DNSBL
fingerprint-coherence fp-coherence UA / screen / timezone lint

Toolkit pipeline: proxy-lane checkfp-coherence audit → automate → cdp-probe runcookie-bridge validate

License

MIT


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

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.4.tar.gz (23.4 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.4-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 files

0.2.2

2 files

0.2.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page