cookie

Basic HTTP cookie parser and serializer for HTTP servers, with zero dependencies and full RFC 6265 support.

Library
npm
v2.0.1
1,531stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
66/100Good
Development Activity56
Maintenance48
Community72
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
89/100Excellent
Architecture88
Code Quality90
Innovation88
Learning Curve90

cookie is a small, focused Node.js library for parsing and serializing HTTP cookies. It reads incoming Cookie headers into plain name-value objects and turns cookie objects back into header strings, and it does the same for Set-Cookie headers including all standard attributes (Domain, Path, Max-Age, Expires, HttpOnly, Secure, SameSite, Priority, and Partitioned).

Built with zero runtime dependencies and shipped as a sub-1.4KB module, it follows RFC 6265 closely while giving you full control over value encoding and decoding. It is the parsing layer beneath much of the Node ecosystem, used by frameworks like Express and countless session and authentication middlewares.

What You Get

  • parseCookie and stringifyCookie for converting between Cookie header strings and plain name-value objects
  • parseSetCookie and stringifySetCookie for reading and writing Set-Cookie headers with all standard attributes
  • Pluggable encode/decode options so you control exactly how cookie values are transformed
  • A zero-dependency, sub-1.4KB, tree-shakeable ESM module with TypeScript types included

Common Use Cases

  • Reading cookies from an incoming request in a raw Node.js HTTP server or a framework
  • Setting session, authentication, or preference cookies with attributes like HttpOnly, Secure, and SameSite
  • Building session or auth middleware that needs precise, spec-compliant cookie handling
  • Serializing and deserializing cookie state without pulling in a heavier framework dependency

Under The Hood

Architecture

The entire library lives in a single module (src/index.ts, ~17KB) exporting four functions: parseCookie, stringifyCookie, parseSetCookie, and stringifySetCookie. Parsing is done with a tight character-index scanning loop over the header string rather than expensive String.split/regex-splitting, locating = and ; delimiters manually for speed. Validation of names, values, domains, and paths uses a set of precompiled RFC 6265 regular expressions defined at module top. Parsed results are collected into a null-prototype NullObject container so attacker-controlled cookie names can never pollute Object.prototype.

Tech Stack

Written in TypeScript with zero runtime dependencies and distributed as a native ESM module ("type": "module", exports: "./dist/index.js", sideEffects: false). It targets Node.js >= 22, is built and tested via @borderless/ts-scripts on top of Vitest, and enforces a strict bundle budget of 1.4KB with size-limit. Bundled .d.ts types ship for TypeScript consumers.

Code Quality

Code quality is high: each of the four functions has a dedicated spec file (parse-cookie.spec.ts, parse-set-cookie.spec.ts, stringify-cookie.spec.ts, stringify-set-cookie.spec.ts) plus snapshot fixtures and benchmark suites that parse real top-site cookie headers. The source is densely commented with inline RFC 6265 grammar references explaining each regular expression, and the public surface is fully and strictly typed.

API Design

The public API is deliberately minimal and symmetric — a parse and a stringify function for each of the Cookie and Set-Cookie header types — which makes it easy to learn and hard to misuse. Both parse functions accept a decode option and both stringify functions accept an encode option, with safe URL-encoding defaults wrapped in try..catch, so custom value transforms are a one-line override. Getting started requires no configuration or setup beyond a single import.

Used by 30 apps in this directory

TypeScript
95%
Apache 2.0

AionUi

AI Agents · Productivity

32,102

Free, open-source Cowork desktop app that unifies Claude Code, Codex, Gemini CLI, and 20+ AI agents into a single platform with multi-agent teams, 24/7 cron automation, and zero-config built-in agent.

View details
88
Repo Health
76
Technical
66
Dependency
Built with
TypeScript95%
Updated today
Python
68%
Other

AutoGPT

Automation · Productivity · AI Assistants

186,687

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
67
Dependency
Built with
Python68%
TypeScript31%
Updated today
Rust
67%
MIT

Bun

Developer Tools

95,452

An all-in-one JavaScript and TypeScript toolkit — one Rust-and-JavaScriptCore binary that replaces Node.js, npm, a bundler, and a test runner with faster equivalents.

View details
92
Repo Health
91
Technical
66
Dependency
Built with
Rust67%
C++19%
Updated today
TypeScript
96%
Other

Cal.diy

Scheduling

47,796

The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.

View details
93
Repo Health
86
Technical
66
Dependency
Built with
TypeScript96%
Updated 1 weeks ago
PHP
79%
Apache 2.0

Coolify

Devops · Hosting Control Panel

60,738

Open-source self-hosted PaaS — deploy apps, databases and 280+ services on your own servers with no vendor lock-in

View details
92
Repo Health
86
Technical
72
Dependency
Built with
PHP79%
Blade18%
Updated yesterday
TypeScript
93%
AGPL 3.0

CourseLit

Ecommerce · Blogging

1,255

Open-source, self-hosted LMS for selling online courses, digital downloads, and building communities on your own branded website.

View details
78
Repo Health
74
Technical
72
Dependency
Built with
TypeScript93%
Updated 4 weeks ago
TypeScript
80%
Other

Directus

CMS · Low Code Platforms

37,462

Connect any SQL database and get instant REST and GraphQL APIs, a visual management Studio, and a native MCP server for AI agents — free for most organizations.

View details
93
Repo Health
82
Technical
78
Dependency
Built with
TypeScript80%
Vue18%
Updated yesterday
TypeScript
92%
MIT

Dittofeed

Marketing · Automation

2,903

Open-source omni-channel customer engagement platform for automating transactional and marketing messages via email, SMS, WhatsApp, Slack, and mobile push.

View details
54
Repo Health
75
Technical
63
Dependency
Built with
TypeScript92%
Updated 4 months ago
TypeScript
95%
AGPL 3.0

Docmost

Productivity · Note Taking · Collaboration

21,411

Self-hosted collaborative wiki and knowledge base with real-time editing, diagrams, AI assistance, and enterprise access controls — a modern alternative to Confluence and Notion.

View details
89
Repo Health
70
Technical
71
Dependency
Built with
TypeScript95%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search