npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mherod/get-cookie

v4.4.1

Published

Node.js module for querying cookies from Chrome, Firefox, and Safari browsers

Readme

get-cookie 🍪

Extract cookies from your browser's local storage and use them programmatically. This tool reads browser databases directly, handles decryption, and outputs cookies you can use in API calls, testing, or automation.

What it does

The Problem: You're logged into a website in your browser, but you need those same cookies for API testing, automation, or debugging. Manually copying cookies from DevTools is tedious and they expire quickly.

The Solution: get-cookie reads cookies directly from browser databases (Chrome, Firefox, Safari, etc.), handles all the encryption/decryption, and gives you the cookie values to use programmatically.

Quick Start

# Install globally
pnpm add -g @mherod/get-cookie

# Get a specific cookie
get-cookie sessionid example.com

# Get all cookies for a domain  
get-cookie % example.com

# Use in curl/API calls
curl -H "Cookie: auth=$(get-cookie auth api.example.com)" https://api.example.com/user
// Node.js/TypeScript usage
import { getCookie } from "@mherod/get-cookie";

const cookies = await getCookie({
  name: "auth_token",
  domain: "api.example.com",
});

// Use in fetch, axios, etc.
fetch("https://api.example.com/data", {
  headers: {
    Cookie: `auth_token=${cookies[0]?.value}`
  }
});

Common Use Cases

  • API Testing: Extract session cookies to test authenticated endpoints
  • Browser Automation: Get real cookies instead of managing login flows
  • Debugging: Compare cookies across browsers to troubleshoot auth issues
  • CI/CD: Automate authenticated API tests without storing credentials
  • Development: Test with production-like authentication locally

How it works

  1. Locates browser databases on your system (Chrome uses SQLite, Safari uses binary files)
  2. Handles encryption (Chrome's keychain/DPAPI encryption, etc.)
  3. Extracts and parses cookie data
  4. Returns usable values you can immediately use in HTTP requests

No browser automation, no complex setup - just direct database access.

Installation 📦

pnpm add @mherod/get-cookie    # recommended
npm install @mherod/get-cookie # or npm
yarn add @mherod/get-cookie    # or yarn

Node.js Version Requirements 🔧

This project requires Node.js v20.0.0 or v22.0.0. We recommend using nvm to manage your Node.js versions.

# Install the correct Node.js version using nvm
nvm install 22.0.0
nvm use 22.0.0

# Or simply run this in the project directory (we've included an .nvmrc file)
nvm use

The project includes an .nvmrc file that specifies the required Node.js version, so nvm use will automatically switch to the correct version when you're in the project directory.

More Examples

Command Line

# Basic cookie extraction
get-cookie sessionid github.com

# Get all cookies for a domain
get-cookie % api.stripe.com

# Pretty print with metadata
get-cookie auth example.com --render

# JSON output for scripting
get-cookie % example.com --output json

# Specific browser/profile
get-cookie auth example.com --browser chrome --profile "Work"

API Usage

import { getCookie, batchGetCookies } from "@mherod/get-cookie";

// Single cookie
const auth = await getCookie({
  name: "sessionid", 
  domain: "github.com"
});

// Multiple cookies efficiently (2-3x faster than individual calls)
const cookies = await batchGetCookies([
  { name: "auth", domain: "api.example.com" },
  { name: "session", domain: "app.example.com" },
  { name: "csrf", domain: "admin.example.com" }
]);

// Use in HTTP client
const response = await fetch("https://api.github.com/user", {
  headers: {
    "Cookie": `sessionid=${auth[0]?.value}`
  }
});

Real-world Integration

# Test API endpoint with browser cookies
AUTH=$(get-cookie connect.sid api.example.com)
curl -H "Cookie: connect.sid=$AUTH" https://api.example.com/profile

# Compare session across browsers  
echo "Chrome:" && get-cookie JSESSIONID app.example.com --browser chrome
echo "Firefox:" && get-cookie JSESSIONID app.example.com --browser firefox

# Batch export for migration
get-cookie % example.com --output json > cookies-backup.json

Features

  • Multiple browsers: Chrome, Firefox, Safari, Edge, Opera, Arc, Brave - reads from each browser's native storage format
  • Handles encryption: Automatically decrypts Chrome's keychain-encrypted cookies (macOS), DPAPI-encrypted cookies (Windows), and keyring encryption (Linux)
  • Multiple profiles: Works with all browser profiles (Personal, Work, etc.)
  • Batch operations: Get multiple cookies efficiently with built-in SQL optimization (2-3x faster)
  • Cross-platform: macOS, Linux, Windows support
  • Output formats: Raw values, JSON, pretty-printed tables

Browser Support 🌐

Supports 11 major browsers across macOS, Linux, and Windows:

  • Chromium-based: Chrome, Edge, Arc¹, Opera, Opera GX, Chromium, Brave
  • Firefox-based: Firefox, Firefox Developer Edition, Firefox ESR
  • Safari: macOS only

¹ Arc added Windows support in April 2024

→ See complete Browser Support Matrix for detailed platform compatibility

Documentation 📚

Explore our comprehensive docs at mherod.github.io/get-cookie

Contributing 🤝

We welcome contributions! Open an issue or submit a PR to get started.

License 📄

MIT Licensed. Build something amazing.