Xerobit

Cookie Parser: Parse HTTP Cookie Strings

A cookie parser splits an HTTP cookie string into individual name-value pairs and extracts optional attributes like Path, Domain, Expires, Max-Age, Secure and HttpOnly. Paste a raw cookie header below to see the parsed result as formatted JSON or a plain table. Everything runs locally in your browser; nothing is uploaded to any server.

Paste a raw Cookie or Set-Cookie header value.

Result

{
  "session_id": "abc123",
  "theme": "dark"
}

Request cookies vs response cookies

HTTP uses two different headers for cookies, and they have distinct formats. The Cookie header is sent by the browser to the server and contains only simple name-value pairs separated by semicolons, such as theme=dark; session=xyz. There are no attributes in a request cookie header.

The Set-Cookie header is sent by the server to the browser. It includes the name-value pair followed by optional attributes. A server may send multiple Set-Cookie headers in a single response, but when combined into one string for tools like this, attributes are associated with the preceding cookie name. If you need to inspect full HTTP headers including content types and caching directives, consider using an http header parser instead.

Common mistakes when reading cookies

Several pitfalls cause confusion when manually inspecting cookie strings:

  • Treating attributes as separate cookies. In a Set-Cookie string, Path=/ is not a second cookie. It modifies the first one. This tool distinguishes between actual cookie names and known attribute keywords.
  • Ignoring case sensitivity. Attribute names like secure, SECURE and Secure are equivalent per the specification. The parser normalizes them for consistent output.
  • Assuming values are always decoded. Raw cookie strings store encoded values. If you copy a cookie directly from browser developer tools, you may see the encoded form. Always run it through a cookie parser to see the true value.
  • Splitting on all equals signs. A cookie value can legally contain an equals sign, such as base64-encoded data. The parser only splits on the first equals sign to preserve the integrity of the value.

Worked examples

ExampleInputResult
Simple session cookieCookie string: session_id=abc123; Output format: json{ / "session_id": "abc123" / }
Multiple cookies with attributesCookie string: id=a3fWa; Expires=Thu, 21 Oct 2025 07:28:00 GMT; Secure; HttpOnly; theme=dark; Path=/; Output format: json{ / "id": { / "value": "a3fWa", / "Expires": "Thu, 21 Oct 2025 07:28:00 GMT", / "Secure": true, / "HttpOnly": true / }, / "theme": { / "value": "dark", / "Path": "/" / } / }
URL-encoded valueCookie string: user=john%40example.com; lang=en-US; Output format: tableCookies found: 2

FAQ

What does this cookie parser do?

It takes a raw HTTP cookie string and breaks it down into individual name-value pairs, extracting attributes like Path, Domain, Expires, Secure and HttpOnly into a structured format.

Does it handle both Cookie and Set-Cookie headers?

Yes. Simple Cookie headers produce a flat list of pairs. Set-Cookie strings with attributes are parsed so that attributes are correctly associated with their parent cookie.

Are percent-encoded values decoded automatically?

Yes. Values like %40 are converted back to their original characters, matching the behavior of standard URL decoding functions.

Is my cookie data sent to a server?

No. The parsing logic runs entirely in your browser. Your cookie strings are never transmitted anywhere.

What happens if a cookie has no value?

A cookie like token= is valid and will be parsed with an empty string as its value. However, a segment with no name at all will trigger an error.

Can I parse multiple Set-Cookie headers at once?

Yes. Paste each Set-Cookie header on its own line (a leading "Set-Cookie:" or "Cookie:" label is fine) and every line is read as a separate cookie with its own attributes. If the same cookie name appears twice, both are kept as a list.