3 min read

Convert Playwright storageState JSON to cookies.txt

Playwright storageState is a JSON object with a cookies array and origins; paste the file here and the detector unwraps the array — expires: -1 becomes a session cookie, not a timestamp in 1969.

A website cannot call browser.storageState() for you. Dump the file from your test, then convert.

Playwright storageStatePlaywright cookies.txtstorageState to JSONPlaywright expires -1
  1. 1
    Dump storageState

    In a Playwright test or codegen session, await context.storageState({ path: "state.json" }) after login.

  2. 2
    Convert on this page

    Paste the whole file, not just the inner array. You should see a warning: Unwrapped cookies array from a storageState-style object. Output is Netscape for CLI, or switch to JSON Array for CookieMan.

  3. 3
    Use the file

    curl -b cookies.txt, or CookieMan Import of the JSON Array. To feed Playwright again, keep the original storageState — it still has origins localStorage which this converter ignores.

Cookies are credentials. Conversion stays in this page — delete the file when you are done.

Why expires -1 must become a session cookie

Playwright uses expires: -1 for session cookies. Treating that as a Unix timestamp would mark the cookie expired. This parser treats any expiry <= 0 as session (expirationDate omitted). Puppeteer uses the same -1 convention.

storageState fieldCookieMan fieldNotes
cookies[]parsed as JSON arrayWrapper warning emitted
originsignoredlocalStorage is not cookies
expires: -1session cookieNot 1969-12-31
sameSite: "Lax"laxCase-insensitive
sameSite: "None"no_restrictionStill needs Secure in Chrome
Re-importing Netscape into Playwright will not restore origins. For Playwright-to-Playwright, keep storageState. Convert only when the next consumer is curl, wget, yt-dlp or CookieMan.

What this will not do

  • Launch Chromium or read a Playwright profile from disk.
  • Preserve localStorage from origins.
  • Preserve SameSite when the output is Netscape.

Questions people ask

Do I need to extract the cookies array by hand?
No. Objects with a cookies array are unwrapped. A bare array still detects as JSON Array.
Why did my session cookie expire immediately?
An older converter treated -1 as a timestamp. This one does not. Re-paste the storageState file here and export again.
Can I convert cookies.txt back to storageState?
You get a cookie array, not a full storageState document. Wrap it yourself as { "cookies": [...], "origins": [] } if Playwright is the destination.
3 min read

Puppeteer Cookies JSON to cookies.txt

Paste the array from page.cookies() or browser.cookies() and convert it to Netscape or CookieMan JSON. expires -1 is a session cookie; SameSite is kept only in JSON.

Puppeteer cookiespage.cookies JSON Open the guide
3 min read

Selenium get_cookies() to JSON Array

Paste the list from WebDriver get_cookies() — expiry, httpOnly, sameSite — and convert it to CookieMan JSON or cookies.txt. expires ≤ 0 becomes a session cookie.

Selenium cookiesget_cookies JSON Open the guide
3 min read

JSON Array vs cookies.txt Field Mapping

Side-by-side mapping of CookieMan JSON Array fields to Netscape cookies.txt. SameSite, partitionKey and store metadata never survive the seven-column file.

JSON vs cookies.txtcookies.txt field mapping Open the guide

Apply this on live cookies

The converter rewrites files. The extension reads and writes the jar in Chrome, including HttpOnly cookies.

Free and MIT-licensed · Chrome, Edge and other Chromium browsers · Nothing leaves your machine