set-cookie-parser

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

Library
npm
v3.1.2
198 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
58 /100 Fair
Development Activity 68
Maintenance 32
Community 52
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
72 /100 Good
Architecture 70
Code Quality 78
Innovation 52
Learning Curve 88

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
82%
Other

AFFiNE

Collaboration · Note Taking · Productivity

73,040

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
67
Dependency
Built with
TypeScript 82%
Rust 11%
Updated 6 days ago
TypeScript
99%
MIT

GraphQL Hive

Developer Tools · Devops · Monitoring

484

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
69
Dependency
Built with
TypeScript 99%
Updated 5 days ago
TypeScript
67%
MIT

Hoppscotch

Developer Tools

80,529

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
65
Dependency
Built with
TypeScript 67%
Vue 25%
Updated 1 weeks ago
TypeScript
99%
Other

LobeHub

AI Assistants · Automation · Productivity

82,864

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
66
Dependency
Built with
TypeScript 99%
Updated 5 days ago
TypeScript
88%
Apache 2.0

Medplum

Authentication · Databases · Developer Tools

2,709

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
TypeScript 88%
Updated 6 days ago
TypeScript
65%
MIT

Scalar

Developer Tools

16,198

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
65
Dependency
Built with
TypeScript 65%
Vue 30%
Updated 5 days ago

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