mime-db is a comprehensive, machine-readable database of media types and associated metadata. It aggregates data from official sources such as IANA, Apache, and nginx, providing detailed information including common file extensions, compressibility, and default charsets for thousands of MIME types. The current stable version is 1.54.0. The package maintains a frequent release cadence, primarily driven by updates to its upstream data sources and community contributions for custom types. A key differentiator is its minimalist approach: it is distributed as a pure JSON data file with no accompanying logic or API, making it lightweight and un-opinionated. This design ensures maximum flexibility, although consumers must implement their own lookup logic. Crucially, changes to the underlying MIME type data are *not* considered breaking changes under its semver policy for the programmatic API, meaning data can change between minor or patch versions.
npm install mime-dbVerified import paths — ran on the pinned version, not inferred.
Demonstrates importing the mime-db and accessing information for specific MIME types. It also includes example logic for reverse lookup by extension, showing common usage patterns.
If your application relies on specific, stable MIME type data, you must pin your `mime-db` dependency to an exact version (e.g., `"mime-db": "1.54.0"`) rather than using a caret (`^`) or tilde (`~`) range. Alternatively, implement robust error handling or data validation in your application to account for potential data evolution.
Always specify a particular release tag in your CDN URL to ensure stability and compatibility, for example, `https://cdn.jsdelivr.net/gh/jshttp/mime-db@1.54.0/db.json`.
For highly sensitive applications, consider augmenting `mime-db` data with additional custom checks or more specialized MIME type libraries that provide stronger validation or inference logic.
Always check if the returned entry for a MIME type is defined before attempting to access its properties, e.g., `const data = db['unknown/type']; if (data) { /* use data */ }`.Pin your `mime-db` dependency to an exact version in your `package.json` (e.g., `"mime-db": "1.54.0"`) to prevent unexpected data changes. Regularly review release notes for data changes and update the pinned version proactively when desired.
No dependency data recorded yet.