Extract cookies from Standard Firefox or FirefoxPWA profiles for a specific domain, and save them in a ready-to-use text file.
By default, it extracts YouTube cookies, and it supports domain-specific filtering for sites like YouTube, Google, and Twitter.
This tool is especially useful for integrating cookies into third-party applications, enabling them to authenticate or access content as if you were already logged into your browser.
python firefox-cookie-extractor.py [domain] [profile_name_or_ULID] [options]💡 Quick tip:
To extract YouTube cookies from your default Firefox profile, simply run:python firefox-cookie-extractor.py
-h, --help— Show usage instructions with examples--list-profiles— List available profiles (standard by default; combine with--pwafor PWA)--browser-json— Generate abrowser.jsonfile for use with ytmusicapi from cookies and a user-maintained headers template.--pwa— Use a FirefoxPWA profile directory
| Command | Description | Notes |
|---|---|---|
python firefox-cookie-extractor.py |
Extract YouTube cookies from default Firefox profile | Default domain: youtube.com |
python firefox-cookie-extractor.py <domain> |
Extract cookies for a specific domain | Example: github.com |
python firefox-cookie-extractor.py <domain> <profile> |
Extract cookies from a specific profile | Example: twitter.com myprofile.default-release |
python firefox-cookie-extractor.py --list-profiles |
List standard Firefox profiles | Works without <domain> argument |
python firefox-cookie-extractor.py --list-profiles --pwa |
List FirefoxPWA profiles | Requires FirefoxPWA |
python firefox-cookie-extractor.py <domain> <profile> --pwa |
Extract cookies from a FirefoxPWA profile | Example: google.com MyPWAProfile |
python firefox-cookie-extractor.py <domain> --browser-json |
Generate browser.json for ytmusicapi from cookies and headers template |
Requires headers_template.json in script dir |
| # | Command | Description |
|---|---|---|
| 1 | python firefox-cookie-extractor.py |
Extract YouTube cookies from the default Firefox profile |
| 2 | python firefox-cookie-extractor.py github.com |
Extract GitHub cookies from the default Firefox profile |
| 3 | python firefox-cookie-extractor.py twitter.com myprofile.default-release |
Extract Twitter cookies from a specific Firefox profile |
| 4 | python firefox-cookie-extractor.py --list-profiles |
List available standard Firefox profiles |
| 5 | python firefox-cookie-extractor.py --list-profiles --pwa |
List available FirefoxPWA profiles |
| 6 | python firefox-cookie-extractor.py google.com MyPWAProfile --pwa |
Extract Google cookies from a FirefoxPWA profile (by profile name) |
| 7 | python firefox-cookie-extractor.py youtube.com 01H9YQ21CQZJX7WZJ0M5VY8R5T --pwa |
Extract YouTube cookies from a FirefoxPWA profile (by ULID) |
| 8 | python firefox-cookie-extractor.py youtube.com --browser-json |
Generate browser.json by converting user-provided headers_template.json file (including cookies) to JSON format for ytmusicapi |
The script can generate a standard cookie file and a browser.json file.
The script generates a file named:
cookie-[domain]-com.txtFor example:
cookie-github-com.txtCookies are saved in a single-line format, ready for direct use in HTTP headers or tools like:
curl --cookie "$(cat cookie-github-com.txt)" https://www.github.comWhen using the --browser-json flag, the script generates a browser.json file compatible with ytmusicapi.
To use this option, you must create and keep updated a file named headers_template.json in the same directory as the script.
⚠️ This file should contain the full HTTP request headers copied directly from your browser’s DevTools, formatted as plain text lines with the syntax:
Key: Value
Make sure to include the completeCookieheader.
The script will read this file, convert the plain text headers into a JSON object.
Without a properly created and updated headers_template.json, the --browser-json option will not work.
This approach ensures that your authentication data and headers exactly match what your browser sends, enabling seamless access for ytmusicapi.
- Python 3
- Firefox installed with at least one profile
(or FirefoxPWA if using--pwa) - Read access to the
cookies.sqlitedatabase
- Domain-specific filtering for cleaner cookie output
- Automatically detects the default profile
- Manual profile selection supported (name or ULID for PWA)
- Works on Linux, macOS, and Windows
- Temporary database copy to avoid file locks
- Clean, emoji-enhanced CLI output 😎
- Full support for FirefoxPWA
The resulting cookie file contains sensitive session data. Store it securely and avoid sharing it. Rotate or delete cookies if compromised.
Created by dmnmsc
Feel free to fork, improve, or share!
This project is licensed under the GNU General Public License v3.0.
You may freely use, modify, and distribute it under the terms of that license.
Full license text: GNU GPL v3