Cookie Converter Tool

Convert Cookie strings to JSON and back while preserving Path, Domain, Expires, Secure and SameSite attributes, or generate document.cookie assignment code directly.

Input Cookie

Result

About This Tool

The Cookie converter handles the two shapes Cookie data usually takes: parsing a Cookie string copied from the browser into structured JSON, and serialising a Cookie list back into a request header. Attributes such as Path, Domain, Expires, Max-Age, Secure, HttpOnly and SameSite are preserved rather than reduced to name and value pairs.

Another common need is generating document.cookie assignment code. Setting several cookies by hand during debugging is error prone and easy to get attributes wrong, so the tool emits ready-to-paste statements in order.

Key Features

Attributes preserved

Path, Domain, Expires, SameSite, Secure and HttpOnly are parsed and written back.

Two-way conversion

Cookie strings and JSON convert both ways, including multi-line Set-Cookie input.

JS code output

Generates document.cookie statements with single or double quotes.

When to Use It

API debugging

Convert cookies to JSON for test scripts or header configuration.

Reproduce a session

Generate document.cookie statements to restore a login state from the console.

Attribute audit

Check whether production cookies set HttpOnly, Secure and SameSite.

How to Use It

  1. 1Choose Cookie to JSON or Generate JS Code.
  2. 2Paste one or more Cookie lines.
  3. 3Click Convert.
  4. 4Copy the JSON result or the JS statements.

Frequently Asked Questions

Why is Path attached to the previous cookie?

In a Cookie string attributes follow a name=value pair, so they belong to the nearest cookie, matching how browsers parse them.

Can HttpOnly cookies be read?

No. HttpOnly means JavaScript cannot access them, so document.cookie never contains them by design.

Other Tools

CodeSwordsman

100+ technical tools with browser-local processing — your data never leaves your device. Official Microsoft Store desktop apps: free, ad-free, offline.

Completely Free

© 2026 CodeSwordsman All Rights Reserved

Service Terms | Privacy Policy | Help | Version Updates | About Us

This website uses cookies to ensure you get the best experience on our website. Privacy Policy.