3 min read

Build a wget --load-cookies file from JSON

wget --load-cookies reads the same Netscape cookies.txt as curl; convert Chrome JSON to that file here, then pass --keep-session-cookies if you also save the jar — otherwise expiry 0 rows disappear.

wget2 uses the same Netscape shape for --load-cookies. This page does not talk to GNU wget; it only rewrites the file.

wget --load-cookieswget cookies.txtwget --save-cookieswget session cookies
  1. 1
    Export JSON from Chrome

    CookieMan → Export → JSON Array for the current site. Session cookies must be included; they become expiry 0 in Netscape.

  2. 2
    Convert to cookies.txt

    Paste into the converter (output Netscape). Download the file. Tabs and the magic header are written for you.

  3. 3
    Run wget

    Use --load-cookies cookies.txt --save-cookies cookies.txt --keep-session-cookies when you need the jar to still contain session tokens after the run.

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

The --keep-session-cookies trap

wget’s --save-cookies writes Netscape. Without --keep-session-cookies, rows with expiry 0 are omitted on write. Your next --load-cookies then has no session. curl does not have this default; wget does.

            wget --load-cookies cookies.txt --save-cookies cookies.txt \
     --keep-session-cookies \
     https://example.com/dashboard

# wget2
wget2 --load-cookies cookies.txt --save-cookies cookies.txt \
      --keep-session-cookies https://example.com/dashboard
          
If wget reports zero cookies loaded, the file probably has spaces instead of tabs. Paste it here and re-export — Skipped invalid Netscape line.

wget versus curl on the same file

Behaviourcurlwget
Read Netscape-b--load-cookies
Write Netscape-c--save-cookies
Keep expiry 0 on writeDefault keepRequires --keep-session-cookies
HttpOnly prefixWrites and reads #HttpOnly_Reads the same prefix

Questions people ask

Does wget need the # Netscape HTTP Cookie File header?
It is tolerant, but curl and yt-dlp are happier with it. This serializer always writes the header and a trailing newline.
Can I pass JSON to wget?
No. Convert to Netscape first. wget has no JSON cookie reader.
Why did session cookies vanish after wget saved the file?
Missing --keep-session-cookies. Reload the original JSON, convert again, and add the flag.
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
3 min read

HTTPie Session Cookies from JSON

Convert a JSON cookie export into a Cookie header for httpie -A or a Netscape jar for curl-compatible sessions. Domains must be real hosts, not localhost.

HTTPie cookieshttpie session Open the guide
3 min read

Fix #HttpOnly_ Dropped as a Comment

Naive parsers skip every # line and delete HttpOnly session cookies. CookieMan keeps #HttpOnly_ rows. Paste the file here to rewrite it.

#HttpOnly_ commentHttpOnly cookies.txt 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