This JavaScript/Node.js library helps you create, parse, and format HTTP Content-Type headers. It provides functions to parse a Content-Type string into a media type and parameters, and to format an object back into a header value, which is useful when handling HTTP requests and responses.
Project status
- jshttp/content-type appears actively maintained, with upstream activity as recent as 2026-09-16 and a steady stream of recent updates (for example, v3.1.0 on 2026-09-10).
- The update cadence in 2026 looks fairly regular, about every 3 to 4 weeks between v3.1.0 (2026-09-10) and v3.0.0 (2026-08-20), following earlier mid-2026 releases.
AI summary generated
Recent updates
v3.1.0
v3.1.0 focuses on performance improvements for Content-Type parsing and formatting. It also exposes new validation helpers, `isTypeValid` and `isTokenValid`, that are used by `format` to validate types and parameter names.
Featuresv3.0.0
v3.0.0 is published as an ESM-only package. The documented intent is that the API surface (parse/format) remains the same, but the repository changes show broader packaging and runtime requirements changes.
Breakingv2.1.0
v2.1.0 extends the parser to optionally stop parsing at the first comma (intended for `Accept` header media ranges). The code change also adds a new `index` field to the public `ContentType` type and introduces a new `start` option to begin parsing from an arbitrary offset.
Featuresv2.0.0
v2.0.0 is a major rewrite of the library (ported to TypeScript) focused on performance (reported as about 3x faster) and on making `parse` lenient. The documented behavior change is that `parse` no longer throws on invalid input, and a new `options.parameters` flag allows skipping parameter parsing.
Featuresv1.0.5
Release 1.0.5 primarily targets performance in the `contentType.parse` implementation by avoiding unnecessary value escaping work when parsing quoted parameters. The code diff also includes substantial development and CI tooling updates (ESLint, test coverage tooling, GitHub Actions vs Travis), though those are not mentioned in the release notes.
v1.0.4
Release v1.0.4 makes a targeted performance change to the Content-Type parsing logic. Specifically, it avoids running the parameter parsing regular expression when the header contains no parameters.
v1.0.3
v1.0.3 is a small refactor release focused on performance, specifically removing argument reassignment. The main production code changes are in parsing/formatting internals of the HTTP Content-Type header.
v1.0.2
Release 1.0.2 is described as a performance improvement by enabling JavaScript strict mode. The runtime code change is minimal, adding 'use strict' to index.js.
v1.0.1
Release v1.0.1 primarily improves the error message thrown when `contentType.parse` is given req/res-like objects missing a `Content-Type` header. The code change specifically adjusts the validation path for object inputs and the related unit test expectations.
v1.0.0
Release 1.0.0 is an initial implementation, derived from media-typer@0.3.0. No additional features, fixes, security updates, or migration guidance are described in the release notes.