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

http-cookie-file

v1.0.0

Published

Lightweight Node.js library for reading, parsing, and atomically saving HTTP cookie files

Readme

http-cookie-file is an atomic HTTP cookie jar supporting Netscape cookies.txt and JSON formats.


📦 Installation

npm install http-cookie-file

pnpm

pnpm install http-cookie-file

yarn

yarn add http-cookie-file

📖 Usage

Basic Usage

import { CookieFile } from 'http-cookie-file';

const cookies = new CookieFile('./cookies.txt');

// Load existing cookies
await cookies.load();

// Set cookie from raw Set-Cookie header
await cookies.setCookie(
  'sid=abc123; Path=/; Secure; HttpOnly',
  'https://example.com/login'
);

// Generate Cookie request header
const header = await cookies.getCookieHeader('https://example.com/api');
// -> "sid=abc123"

JSON Format

Store cookies in JSON format instead of Netscape format.

const cookies = new CookieFile('./cookies.json', { format: 'json' });
await cookies.setCookie('session=xyz123', 'https://example.com');

Response Header Ingestion

Ingest Set-Cookie headers directly from standard Response or Headers objects.

const response = await fetch('https://example.com/api/login');

// Extract and persist cookies from response
await cookies.setFromResponse(response, 'https://example.com/api/login');

Structured Cookie Operations

Manage individual cookies with structured input, queries, and deletions.

// Add structured cookie
await cookies.set({
  name: 'theme',
  value: 'dark',
  domain: 'example.com',
  path: '/',
  secure: true,
  maxAge: 3600,
});

// Query matched cookies for URL
const list = await cookies.getCookies('https://example.com/dashboard');

// Delete specific cookie
await cookies.delete('theme', { domain: 'example.com', path: '/' });

Session Persistence & Auto-Save

Configure automatic disk persistence and session cookie behavior.

const cookies = new CookieFile('./cookies.txt', {
  autoSave: true, // Automatically persist changes to disk
  persistSessionCookies: false, // Exclude session cookies from disk writes
});

Utilities

Exposes low-level RFC 6265 and Netscape parser functions.

import {
  parseNetscapeCookies,
  parseSetCookie,
  serializeNetscapeCookies,
} from 'http-cookie-file';

// Parse Netscape cookies format text
const list = parseNetscapeCookies(rawContent);

// Serialize cookie list to Netscape format
const content = serializeNetscapeCookies(list);

📚 Documentation

For all configuration options, please see the API docs.

🤝 Contributing

Want to contribute? Awesome! To show your support is to star the project, or to raise issues on GitHub.

Thanks again for your support, it is much appreciated! 🙏

License

MIT © Shahrad Elahi and contributors.