# Netscape cookie format explained

> A cookies.txt line holds domain, subdomain flag, path, secure flag, expiry, name and value, split by tabs. The HttpOnly prefix is not a comment.

Source: https://mosaicbrowser.com/guides/netscape-cookie-format-explained

## The Netscape cookie format, explained field by field

The Netscape cookie format is the plain-text cookies.txt file that curl and yt-dlp read: one cookie per line, seven tab-separated fields in the order domain, include subdomains, path, secure, expiry, name and value. Lines starting with # are comments, except the HttpOnly prefix, which marks an HttpOnly cookie.

![7: Seven fields, one cookie per line, beside a screenshot: importing a cookie jar into a Mosaic profile](https://mosaicbrowser.com/covers/netscape-cookie-format-explained.webp)

A Netscape cookie file is the oldest portable form a cookie has. Netscape invented it so cookies would survive a browser restart, curl adopted it to share cookies with browsers, and then, in curl's own words, the browsers moved away from it: "Modern browsers no longer use it, while curl still does" ([curl docs](https://curl.se/docs/http-cookies.html)). It lives on because command-line tools read it. When yt-dlp, curl or a scraper asks for `cookies.txt`, this is the format it means.

## What a cookies.txt file looks like

Here is a three-cookie file. The gaps between columns are single tab characters.

```
# Netscape HTTP Cookie File

.example.com	TRUE	/	TRUE	1798761600	theme	dark
#HttpOnly_.example.com	TRUE	/	TRUE	1798761600	sessionid	8f2c1e9a
shop.example.com	FALSE	/cart	FALSE	0	cart	3

```

Lines that start with `#` are comments and blank lines are ignored. The first line is a comment too, but some readers insist on it: yt-dlp requires the first line to be `# HTTP Cookie File` or `# Netscape HTTP Cookie File` ([yt-dlp FAQ](https://github.com/yt-dlp/yt-dlp/wiki/FAQ)). When we fed that file to curl 8.7.1 with `-b cookies.txt -c out.txt`, curl wrote it back with its own header, `# This file was generated by libcurl! Edit at your own risk.`, and the same three cookies.

## The Netscape cookie format explained, field by field

Every cookie line has seven fields, in this order. The names and examples follow curl's documentation of the format.

| # | Field | Example | What it means |
| --- | --- | --- | --- |
| 1 | Domain | `.example.com` | The host the cookie belongs to |
| 2 | Include subdomains | `TRUE` | `TRUE` sends it to every subdomain too; `FALSE` to that exact host only |
| 3 | Path | `/` | The cookie is sent only for URLs under this path |
| 4 | Secure | `TRUE` | `TRUE` means HTTPS only |
| 5 | Expires | `1798761600` | Seconds since 1 January 1970; `0` means a session cookie |
| 6 | Name | `theme` | The cookie's name |
| 7 | Value | `dark` | The cookie's value, the last thing on the line |

`1798761600` is midnight UTC on 1 January 2027. Fields 2 and 4 are written in capitals by convention, and most readers compare them without caring about case.

Fields 1 and 2 describe the same thing twice, and they should agree. A domain written with a leading dot goes with `TRUE` in field 2; a bare host such as `shop.example.com` goes with `FALSE`. Cookie-Editor's reader takes its host-only flag from field 2 alone ([Cookie-Editor source](https://github.com/moustachauve/cookie-editor/blob/master/interface/lib/netscapeFormat.js)), so a file where the two disagree imports as whatever field 2 says.

Mosaic is a desktop app

Email yourself the link and open it on your computer.

[How it works: Cookie jars](https://mosaicbrowser.com/features/cookie-jars)

## The #HttpOnly_ prefix

HttpOnly is not a column. A cookie with the HttpOnly attribute is written with `#HttpOnly_` stuck to the front of its domain, as on the second line of the example. curl's documentation calls it the one exception to the comment rule: "Lines that start with # are treated as comments. An exception is lines that start with #HttpOnly_".

Hand-written parsers go wrong here, and it costs them the most important cookies. Session tokens are the cookies sites mark HttpOnly, so a reader that skips every line starting with `#` imports the theme preference and the cart and drops the login. If an import "worked" and you are still signed out, look for `#HttpOnly_` lines first.

## What the format cannot hold

The format was fixed long before several cookie attributes existed, so a conversion to Netscape loses them:

- SameSite: Chrome's cookie API stores Strict, Lax or None for each cookie ([chrome.cookies](https://developer.chrome.com/docs/extensions/reference/api/cookies)); a cookies.txt line has nowhere to put it.
- The partition key and the priority, both columns in Chrome DevTools' cookie table ([DevTools docs](https://developer.chrome.com/docs/devtools/application/cookies)).
- In practice, whether a session cookie is a session cookie. The format allows `0`, but Cookie-Editor's exporter writes session cookies with an expiry one day ahead, with a comment explaining that this stops them being discarded when imported back. A cookie exported that way stops working the next day.

That is why we suggest JSON for moving a session from one browser to another, and Netscape only when the tool at the other end needs it.

## Tabs, spaces and line endings

The fields are separated by tab characters, and that is the most common reason a cookies.txt file is rejected. A file pasted through a chat window or a web form often arrives with spaces instead of tabs. Cookie-Editor splits each line on tabs and rejects any line that does not come out as exactly seven fields. Line endings matter to yt-dlp as well: its FAQ asks for CRLF on Windows and LF on macOS and Linux, and says an `HTTP Error 400: Bad Request` when using `--cookies` is "a good sign of invalid newline format".

## Converting cookies.txt to JSON

Browser extensions and most automation tools want JSON. This Python script turns a cookies.txt into the JSON array Cookie-Editor exports, with the same key names Chrome's cookie API uses. It assumes real tabs, as the format does.

```
import json, sys

cookies = []
for line in open(sys.argv[1], encoding="utf-8"):
    line = line.rstrip("\r\n")
    http_only = line.startswith("#HttpOnly_")
    if http_only:
        line = line[len("#HttpOnly_"):]
    if not line.strip() or line.startswith("#"):
        continue
    domain, subdomains, path, secure, expires, name, value = line.split("\t")
    cookie = {
        "domain": domain,
        "hostOnly": subdomains.upper() != "TRUE",
        "path": path,
        "secure": secure.upper() == "TRUE",
        "httpOnly": http_only,
        "name": name,
        "value": value,
    }
    if int(expires) == 0:
        cookie["session"] = True
    else:
        cookie["expirationDate"] = int(expires)
    cookies.append(cookie)

print(json.dumps(cookies, indent=2))

```

Run it as `python3 cookies_to_json.py cookies.txt > cookies.json`. On the example file it prints three cookies, with `"httpOnly": true` on `sessionid` and `"session": true` on `cart`. A line with the wrong number of fields stops it with a `ValueError`, which is what you want: a converter that skips bad lines quietly hands you a session with a hole in it.

## How Mosaic reads cookies.txt

A Mosaic profile's **Cookies** tab takes a Netscape file as it is, alongside JSON and a pasted Cookie header, and we wrote its reader around the failures above. It splits a line on any run of whitespace, so the tabs-turned-to-spaces file loads; we checked that the example above gives the same three cookies either way. It keeps `#HttpOnly_` lines as HttpOnly cookies. It treats the rest of the line after the name as the value. And a line it cannot read is reported by number, as "Line 6 is not a Netscape cookie row", instead of being dropped.

Mosaic reads cookies.txt but does not write it: **Export current** gives the profile's jar as JSON. Where those exports come from and go to in Chrome is in [how to export cookies from Chrome](https://mosaicbrowser.com/guides/export-cookies-from-chrome) and [how to import cookies into Chrome](https://mosaicbrowser.com/guides/import-cookies-into-chrome); carrying a whole signed-in session across is [moving a logged-in session to another browser](https://mosaicbrowser.com/guides/move-a-logged-in-session-to-another-browser). Scripts that load cookies into many profiles at once use the local API, covered in [automating multiple browser profiles](https://mosaicbrowser.com/guides/automate-multiple-browser-profiles).

## Sources

1. [curl: HTTP Cookies (cookie file format)](https://curl.se/docs/http-cookies.html), read November 2, 2026
2. [yt-dlp FAQ: How do I pass cookies to yt-dlp?](https://github.com/yt-dlp/yt-dlp/wiki/FAQ), read November 2, 2026
3. [Cookie-Editor source: Netscape format](https://github.com/moustachauve/cookie-editor/blob/master/interface/lib/netscapeFormat.js), read November 2, 2026
4. [Chrome Extensions: chrome.cookies API](https://developer.chrome.com/docs/extensions/reference/api/cookies), read November 2, 2026
5. [Chrome DevTools: View, add, edit, and delete cookies](https://developer.chrome.com/docs/devtools/application/cookies), read November 2, 2026

## Questions

### What does the 0 in the expiry column mean?

Zero means a session cookie, one with no expiry date that a browser forgets when it closes. Any other number is the expiry time in seconds since 1 January 1970.

### Is #HttpOnly_ a comment?

No. It is a prefix on a real cookie line, and it means the cookie has the HttpOnly attribute. curl documents it as the one exception to the rule that lines starting with # are comments.

### Can a cookies.txt file use spaces instead of tabs?

Strictly, no: curl's description of the format says the seven fields are separated by tab characters. Some readers accept spaces anyway, but Cookie-Editor's importer, for one, does not.

### Why does yt-dlp reject my cookies.txt?

Usually the first line or the line endings. yt-dlp wants the first line to be # HTTP Cookie File or # Netscape HTTP Cookie File, and line endings that match your system; its FAQ says an HTTP Error 400 with --cookies is a sign of the wrong newlines.

## Related

[How to export cookies from Chrome](https://mosaicbrowser.com/guides/export-cookies-from-chrome): Chrome has no cookie export button. Use a cookie extension for one site, or yt-dlp for every site, and treat the file you get like a password.

[How to import cookies into Chrome](https://mosaicbrowser.com/guides/import-cookies-into-chrome): Chrome has no cookie import. Paste the file into a cookie extension's Import box, add single cookies in DevTools, or set them in a script.

[How to move a logged-in session to another browser](https://mosaicbrowser.com/guides/move-a-logged-in-session-to-another-browser): Browser import tools don't carry cookies. Export the site's cookies as JSON, import them into the other browser, and don't press Log out in the old one.

[How to automate multiple browser profiles](https://mosaicbrowser.com/guides/automate-multiple-browser-profiles): Automate multiple browser profiles by giving each account a persistent profile, starting each from a script and attaching Playwright or Puppeteer over CDP.

[How to export profiles from Octo Browser](https://mosaicbrowser.com/guides/export-profiles-from-octo-browser): To export profiles from Octo Browser you get encoded .octo files for other Octo accounts, at 0.5 tokens each. Its API returns readable JSON instead.







[How to export profiles from Dolphin Anty](https://mosaicbrowser.com/guides/export-profiles-from-dolphin-anty): To export profiles from Dolphin Anty, take cookies and local storage from the app and the settings from its API, one JSON record per profile.

[How to export profiles from GoLogin](https://mosaicbrowser.com/guides/export-profiles-from-gologin): To export profiles from GoLogin, its button writes a CSV of settings without cookies. Its API returns each profile as JSON, and cookies export per profile.

## Run this guide on your own accounts

Every Mosaic profile is a fingerprint, a proxy IP and a cookie jar that agree with each other, kept on your computer. Free covers 3 profiles with no card, and Pro is $25 a month for any number of them.

Mosaic is a desktop app

Email yourself the link and open it on your computer.
