3 min read

Build an Axios Cookie header from JSON cookies

Axios in Node sends a Cookie header you attach yourself; convert a JSON export to that name=value; name=value line here. In a browser, Axios cannot force HttpOnly cookies — the header is ignored or forbidden.

This is the request header, not Set-Cookie. If you have response headers, use Cookie header vs Set-Cookie first.

Axios Cookie headerAxios cookiesJSON to Cookie headeraxios headers Cookie
  1. 1
    Export JSON from Chrome

    CookieMan JSON Array. Remove cookies you do not want on the API call.

  2. 2
    Convert to Header String

    Paste below. Copy the output. The serializer does not emit a Cookie: prefix — Axios wants the value only.

  3. 3
    Attach in Node Axios

    Set headers.Cookie on the instance or the request. Do not ship the header in frontend bundles.

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

Node Axios snippet

            import axios from "axios";

const cookieHeader = "session_id=abc123; theme=dark"; // from this converter

const api = axios.create({
  baseURL: "https://api.example.com",
  headers: { Cookie: cookieHeader },
});

const { data } = await api.get("/v1/me");
          
Browsers block setting Cookie from JavaScript for your own origin’s HttpOnly cookies, and CORS plus forbidden headers stop you from attaching Cookie to cross-site XHR. This header path is for Node, curl, and other non-browser HTTP clients.

Header versus a real cookie jar

ApproachKeeps Domain / Secure / HttpOnly?Where it works
headers.Cookie stringNo — values onlyNode Axios, httpie, fetch in Node
Netscape jar + curlDomain, Secure, HttpOnly prefixCLI
CookieMan Import JSONFull attributesChrome / Edge

tough-cookie and axios-cookiejar-support exist if you need a jar in Node. This page stops at producing the header or a cookies.txt you can load elsewhere.

Questions people ask

Why does Axios in the browser ignore my Cookie header?
Cookie is a forbidden request header in browsers. Use CookieMan to write the live jar, or run Axios in Node.
Should the output include the Cookie: prefix?
This serializer writes name=value; name=value only. Add the header name in Axios. Pasting a line that already starts with Cookie: is accepted on input.
How do I keep Set-Cookie from the Axios response?
In Node, read response.headers["set-cookie"], paste those lines here as Set-Cookie format, convert to JSON or Netscape. Browsers store Set-Cookie themselves.
3 min read

Postman Cookie Header to JSON

Paste a Postman Cookie header and turn name=value pairs into a JSON array. Domains default to localhost until you set them — then import or send via curl.

Postman cookiesPostman Cookie header Open the guide
3 min read

Cookie Header vs Set-Cookie Conversion

A Cookie request header is name=value pairs. Set-Cookie response lines carry Domain, Path, flags and Expires. Convert each separately — they are not interchangeable.

Cookie vs Set-CookieSet-Cookie to JSON 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

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