unjar reads cookies from local browser profiles and exports them as a cookies.txt file, JSON, or a Cookie: header. Use it as a CLI or Rust library.
Install using Cargo:
cargo install unjarShow discovered browser profiles:
unjar listShow help without reading any cookies:
unjarDump cookies for one or more domains using Chrome by default:
unjar x.comunjar x.com t.coExplicitly dump every cookie from the selected browser or profile:
unjar allSelect a profile by ID, unique display name, or path:
unjar -p 'Profile 1' x.comunjar -p 'Work' x.comunjar -b chromium -p /path/to/profile x.comWrite cookies to a file and use it with curl or yt-dlp:
unjar -o cookies.txt x.com
curl -b cookies.txt https://x.com/...unjar list prints each discovered profile's browser, local profile ID, default selection, and path. A unique ID or display name works without --browser; use --browser to disambiguate duplicates. An explicit path may point to a profile directory or directly to its cookie database. For a copied or otherwise unknown path, also pass --browser so unjar can select the right decryption backend.
The header format accepts exactly one host. It includes every cookie whose stored domain matches that host; it does not evaluate URL path, scheme, expiration, or other request attributes. Use JSON or Netscape format when exporting multiple domains or all.
cargo add unjar --no-default-featuresuse unjar::Browser;
fn main() -> unjar::Result<()> {
let profile = Browser::Chrome.find_profile("Default")?;
let jar = profile.cookies()?.domain("x.com");
for c in jar.iter() {
println!("{}={}", c.name, c.value);
}
// or hand it straight to an HTTP client
let header = jar.to_header();
Ok(())
}Pipe your browser cookies into the GitLab API to show the user logged into your browser:
unjar gitlab.com | curl -b - https://gitlab.com/api/v4/userThe GitLab API accepts the browser session cookie and returns the current user as JSON. The -b - argument tells curl to read the Netscape cookie file from stdin.
twscrape accepts a cookie header from stdin. Log into X in your browser, then pipe the cookies straight into a local account:
unjar -f header x.com | twscrape add_cookie my_accountmy_account is a local identifier in twscrape; it does not need to match the X username stored in the cookies.
When the selected profile is logged into X, unjar x.com includes the auth_token and ct0 cookies that twscrape needs, plus the rest of the matching session cookies.
Legend: ✅ tested · 🟡 implemented, not yet tested · 🚧 not implemented.
| Browser | macOS | Linux | Windows |
|---|---|---|---|
| Chrome | ✅ | 🟡 | 🚧 |
| Chromium | 🟡 | 🟡 | 🚧 |
| Edge | ✅ | 🟡 | 🚧 |
| Brave | 🟡 | 🟡 | 🚧 |
| Firefox | ✅ | 🟡 | 🟡 |
| Safari | ✅ | — | — |
Chrome, Edge, Firefox, and Safari on macOS have been verified end-to-end, including Safari's named profiles. Linux Chromium decryption currently relies on the peanuts fallback and will not decrypt profiles that store the key in the system keyring (v11). Windows support is not implemented yet.
Current Chromium-based browsers on Windows protect cookies with App-Bound Encryption, which only the browser itself can decrypt. Supporting current Chrome, Edge, or Brave therefore requires an explicit browser integration such as a user-installed extension; unjar does not attempt to bypass this protection through elevation or process injection.
All contributions are welcome! Feel free to open an issue or submit a pull request.
Distributed under the MIT License.