Gathering detailed insights and metrics for mime-types
Gathering detailed insights and metrics for mime-types
Gathering detailed insights and metrics for mime-types
Gathering detailed insights and metrics for mime-types
The ultimate javascript content-type utility.
npm install mime-types
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.4
Supply Chain
99.5
Quality
83.2
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
13,742,281,481
Last Day
5,038,401
Last Week
76,384,624
Last Month
331,134,142
Last Year
3,027,434,549
MIT License
1,395 Stars
492 Commits
138 Forks
20 Watchers
12 Branches
28 Contributors
Updated on Jul 03, 2025
Minified
Minified + Gzipped
Latest Version
3.0.1
Package Id
mime-types@3.0.1
Unpacked Size
21.82 kB
Size
6.99 kB
File Count
6
NPM Version
10.9.0
Node Version
22.10.0
Published on
Mar 26, 2025
Cumulative downloads
Total Downloads
The ultimate javascript content-type utility.
Similar to the mime@1.x
module, except:
mime-types
simply returns false
, so do
var type = mime.lookup('unrecognized') || 'application/octet-stream'
.new Mime()
business, so you could do var lookup = require('mime-types').lookup
..define()
functionality.lookup(path)
Otherwise, the API is compatible with mime
1.x.
This is a Node.js module available through the
npm registry. Installation is done using the
npm install
command:
1$ npm install mime-types
This package considers the programmatic api as the semver compatibility. Additionally, the package which provides the MIME data
for this package (mime-db
) also considers it's programmatic api as the semver contract. This means the MIME type resolution is not considered
in the semver bumps.
In the past the version of mime-db
was pinned to give two decision points when adopting MIME data changes. This is no longer true. We still update the
mime-db
package here as a minor
release when necessary, but will use a ^
range going forward. This means that if you want to pin your mime-db
data
you will need to do it in your application. While this expectation was not set in docs until now, it is how the pacakge operated, so we do not feel this is
a breaking change.
If you wish to pin your mime-db
version you can do that with overrides via your package manager of choice. See their documentation for how to correctly configure that.
All mime types are based on mime-db, so open a PR there if you'd like to add mime types.
1var mime = require('mime-types')
All functions return false
if input is invalid or not found.
Lookup the content-type associated with a file.
1mime.lookup('json') // 'application/json' 2mime.lookup('.md') // 'text/markdown' 3mime.lookup('file.html') // 'text/html' 4mime.lookup('folder/file.js') // 'application/javascript' 5mime.lookup('folder/.htaccess') // false 6 7mime.lookup('cats') // false
Create a full content-type header given a content-type or extension.
When given an extension, mime.lookup
is used to get the matching
content-type, otherwise the given content-type is used. Then if the
content-type does not already have a charset
parameter, mime.charset
is used to get the default charset and add to the returned content-type.
1mime.contentType('markdown') // 'text/x-markdown; charset=utf-8'
2mime.contentType('file.json') // 'application/json; charset=utf-8'
3mime.contentType('text/html') // 'text/html; charset=utf-8'
4mime.contentType('text/html; charset=iso-8859-1') // 'text/html; charset=iso-8859-1'
5
6// from a full path
7mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8'
Get the default extension for a content-type.
1mime.extension('application/octet-stream') // 'bin'
Lookup the implied default charset of a content-type.
1mime.charset('text/markdown') // 'UTF-8'
A map of content-types by extension.
A map of extensions by content-type.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
project has 24 contributing companies or organizations
Details
Reason
no dangerous workflow patterns detected
Reason
update tool detected
Details
Reason
license file detected
Details
Reason
GitHub workflow tokens follow principle of least privilege
Details
Reason
0 existing vulnerabilities detected
Reason
security policy file detected
Details
Reason
10 out of 13 merged PRs checked by a CI test -- score normalized to 7
Reason
SAST tool detected but not run on all commits
Details
Reason
dependency not pinned by hash detected -- score normalized to 6
Details
Reason
Found 11/26 approved changesets -- score normalized to 4
Reason
3 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 3
Reason
branch protection not enabled on development/release branches
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-06-30T21:29:41Z
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreLast Day
-4.3%
5,038,401
Compared to previous day
Last Week
-5.8%
76,384,624
Compared to previous week
Last Month
12.1%
331,134,142
Compared to previous month
Last Year
22.3%
3,027,434,549
Compared to previous year