3 min read

Feed HTTPie a Cookie header or cookies.txt from JSON

HTTPie sends cookies as a Cookie header or via a session file; convert JSON cookies to that header here (output is preset to Header String). HTTPie is not CookieMan — paste an export, do not expect this page to read ~/.config/httpie.

A header has no Domain. That is correct for a single http call to one host. For a reusable jar, switch output to Netscape instead.

HTTPie cookieshttpie sessionHTTPie Cookie headerhttpie cookies.txt
  1. 1
    Export JSON from the browser

    CookieMan JSON Array for the API host. Drop cookies you do not want on the request.

  2. 2
    Convert to a Cookie header

    Paste below. Copy the Header String output. For a Netscape jar, change the dropdown to Netscape and save cookies.txt.

  3. 3
    Send with HTTPie

    Pass Cookie:... as a header, or use an HTTPie session that already stored cookies from a previous response.

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

HTTPie commands that consume the output

            # header string from this page:
http GET https://api.example.com/v1/me \
  "Cookie: session_id=abc123; theme=dark"

# persist Set-Cookie from the server into an HTTPie session
http --session=./api.json GET https://api.example.com/v1/login
          
HTTPie sessions are JSON, but not CookieMan JSON. Do not paste an HTTPie session document here. Paste a cookie array, a header, or Netscape.

What the Cookie header drops

Kept in Header StringDropped
name=value pairs, semicolon-separateddomain, path, expiry, Secure, HttpOnly, SameSite, partitionKey

That loss is why a header is the right artefact for one request and the wrong artefact for Chrome Import. For import, keep JSON Array.

Questions people ask

Can I paste an HTTPie session JSON file?
No. Extract cookies from it or export JSON from CookieMan. An HTTPie session document has a different schema and will not detect as a cookie array.
Should I use a Netscape file with HTTPie?
HTTPie prefers headers or its own session files. Use Netscape when the next process is curl/wget. Convert twice if you need both.
Why is HttpOnly missing from the header?
Request Cookie headers never include attributes. HttpOnly only exists on stored cookies and Set-Cookie. The values still appear in the header — the flag does not.
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

Axios Cookie Header from JSON Export

Convert a JSON cookie array to a Cookie header for Axios in Node. Browsers ignore this header. HttpOnly cannot appear on the wire.

Axios Cookie headerAxios cookies Open the guide
3 min read

Python Requests CookieJar from JSON

Convert browser JSON to Netscape for Requests via MozillaCookieJar, or to a Cookie header. Set domains before you call the host.

Python requests cookiesMozillaCookieJar 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