set-cookie-parser

Parse raw Set-Cookie header values into structured JavaScript cookie objects

Library
npm
v3.1.2
197stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
60/100Good
Development Activity76
Maintenance32
Community52
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
72/100Good
Architecture70
Code Quality78
Innovation52
Learning Curve88

set-cookie-parser converts raw Set-Cookie header values into plain JavaScript objects with named fields (name, value, path, domain, expires, maxAge, secure, httpOnly, sameSite, partitioned), removing the need to hand-write a Set-Cookie regex. It accepts a single header string, an array of header values, a Node.js http.IncomingMessage response, or a WHATWG fetch() Response object, and normalizes all of them into the same output shape.

It can return either an array of cookie objects or a name → cookie map ({map: true}), and is commonly paired with the cookie npm package, whose input format its output loosely mirrors — making it a natural fit anywhere server or edge code needs to inspect cookies a backend response is trying to set.

What You Get

  • Accepts a single header value, an array, a Node.js response, or a fetch() Response object as input
  • Returns an array of cookie objects or, with {map: true}, a name-to-cookie-object map
  • Full field parsing: name, value, path, domain, expires, maxAge, secure, httpOnly, sameSite, partitioned
  • Optional value decoding via decodeValues (defaults to true)
  • Ships as a dual ESM/CJS package with bundled TypeScript type definitions

Common Use Cases

  • Inspecting Set-Cookie headers returned by an upstream API in a Node.js HTTP client or proxy
  • Reading and forwarding session cookies in serverless/edge functions using the fetch() Response API
  • Testing HTTP endpoints that set cookies, by parsing response headers into assertable objects
  • Building custom cookie-jar or session-management logic on top of raw fetch/http responses

Under The Hood

Architecture The library is a single module (lib/set-cookie.js, ~270 lines) exposing a small set of functions — parse(), parseString(), splitCookiesString(), and parseSetCookie() — that first split a combined Set-Cookie header string on comma boundaries (careful to avoid splitting inside Expires= date values), then tokenize each cookie string on ; to extract attribute key/value pairs into a plain object. Tech Stack Zero runtime dependencies; it ships as a native ESM module (type: module) with a build step (build-cjs.js) that generates a CommonJS dist/set-cookie.cjs for require() consumers, and devDependencies limited to mocha/sinon for testing, tsd for type-testing, and eslint/prettier for style. Code Quality Tests in test/ cover parsing from raw strings, arrays, Node response objects, and fetch Response objects, with test-d/ providing tsd-based type-level tests to ensure the shipped .d.ts definitions stay accurate; CI runs lint, unit tests, and typecheck on every push. API Design The API surface is intentionally tiny — one main parse() function handling four different input shapes (string, array, Node response, fetch Response) transparently, with an options object (decodeValues, map) covering the only real behavioral variation — making it a near-zero-boilerplate drop-in for any code that already has a response object in hand.

Used by 6 apps in this directory

TypeScript
88%
Other

AFFiNE

Productivity · Project Management · Note Taking

71,668

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript88%
Updated today
TypeScript
98%
MIT

GraphQL Hive

Developer Tools · Devops · Monitoring

485

Open-source GraphQL schema registry and observability platform with breaking change detection, federation support, and CI/CD integration for teams of any size.

View details
90
Repo Health
81
Technical
70
Dependency
Built with
TypeScript98%
Updated today
TypeScript
67%
MIT

Hoppscotch

Developer Tools

80,055

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
66
Dependency
Built with
TypeScript67%
Vue23%
Updated 3 days ago
TypeScript
99%
Other

LobeHub

AI Assistants · Productivity · Automation

81,816

Your Chief Agent Operator — build, schedule, and collaborate with an entire AI team in one self-hostable workspace.

View details
92
Repo Health
81
Technical
72
Dependency
Built with
TypeScript99%
Updated today
TypeScript
88%
Apache 2.0

Medplum

Developer Tools · Databases · Authentication

2,614

An open-source, FHIR-native healthcare platform that gives developers a compliant backend, authentication, a React component library, and serverless bots to build clinical applications in weeks instead of years.

View details
93
Repo Health
90
Technical
72
Dependency
Built with
TypeScript88%
MDX10%
Updated today
TypeScript
60%
MIT

Scalar

Developer Tools

15,944

Beautiful, interactive OpenAPI documentation with a built-in offline-first API client and multi-language code generation — all in one open-source platform.

View details
90
Repo Health
89
Technical
66
Dependency
Built with
TypeScript60%
Vue35%
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