3 min read

Convert Puppeteer page.cookies() JSON to cookies.txt

Puppeteer page.cookies() returns a JSON array of cookie objects; paste it here to write Netscape cookies.txt for curl or a cleaned JSON array for CookieMan. This is not the Puppeteer documentation — it is the conversion step after you dump cookies from a browser you launched.

Puppeteer cookiespage.cookies JSONPuppeteer to cookies.txtPuppeteer CookieParam
  1. 1
    Dump cookies from Puppeteer

    JSON.stringify(await page.cookies()) after the page has set them. Newer Puppeteer also has browser.cookies() across contexts.

  2. 2
    Convert here

    Paste the array. Output Netscape for CLI. Switch to JSON Array to import in Chrome with CookieMan.

  3. 3
    Reload or send

    page.setCookie(...cookies) with the JSON objects, or curl -b cookies.txt. You must be on a matching origin before setCookie.

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

Puppeteer CookieParam fields

PuppeteerAfter parseDropped on Netscape export?
name, value, domain, pathkeptNo
expires Unix secondsexpirationDateNo
expires: -1sessionWritten as 0
httpOnly, securekeptHttpOnly → prefix; Secure → column 4
sameSitekept in JSONYes — no Netscape column
size, session (boolean)ignored extrasYes
partitionKey (if present)kept in JSON when topLevelSite existsYes on Netscape
            const cookies = await page.cookies();
console.log(JSON.stringify(cookies, null, 2));

// after converting to JSON Array in the tool:
await page.setCookie(...JSON.parse(fs.readFileSync("cookies.json", "utf8")));
          
If your dump is wrapped as { "cookies": [...] }, it is treated as storageState and unwrapped. See Playwright storageState.

setCookie origin rules still apply

Puppeteer talks to Chrome. SameSite=None still requires secure: true. __Host- still forbids domain. The converter will not make Chrome accept an illegal cookie — SameSite=None without Secure.

Questions people ask

page.cookies() vs document.cookie?
page.cookies() uses the DevTools protocol and includes HttpOnly. document.cookie does not. Always dump via Puppeteer’s API.
Why is size missing after conversion?
CookieMan JSON does not store size. Chrome computes it. Re-reading cookies from the browser restores it.
Can I convert cookies.txt back for setCookie?
Yes — paste Netscape, output JSON Array, pass the objects to setCookie. SameSite will be unspecified unless you set it.
3 min read

Playwright storageState to cookies.txt

Paste a Playwright storageState file. The converter unwraps the cookies array, treats expires -1 as a session cookie, and writes Netscape for curl or Chrome JSON.

Playwright storageStatePlaywright cookies.txt 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

curl -b cookies.txt from JSON Export

Turn a Chrome JSON export into the Netscape file curl -b and -c expect: tabs, #HttpOnly_ prefixes, Unix-second expiry and a trailing newline.

curl cookies.txtcurl -b cookies 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