Gathering detailed insights and metrics for mime
Gathering detailed insights and metrics for mime
Gathering detailed insights and metrics for mime
Gathering detailed insights and metrics for mime
mime-db
Media Type Database
mime-types
The ultimate javascript content-type utility.
@types/mime
Stub TypeScript definitions entry for mime, which provides its own types definitions
whatwg-mimetype
Parses, serializes, and manipulates MIME types, according to the WHATWG MIME Sniffing Standard
npm install mime
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.7
Supply Chain
99.6
Quality
81.6
Maintenance
100
Vulnerability
100
License
TypeScript (70.33%)
JavaScript (28.54%)
Shell (1.13%)
Total Downloads
15,860,233,425
Last Day
11,731,586
Last Week
71,526,078
Last Month
313,153,082
Last Year
3,389,747,756
MIT License
2,276 Stars
407 Commits
317 Forks
20 Watchers
2 Branches
49 Contributors
Updated on May 29, 2025
Minified
Minified + Gzipped
Latest Version
4.0.7
Package Id
mime@4.0.7
Unpacked Size
105.49 kB
Size
27.96 kB
File Count
22
NPM Version
10.8.2
Node Version
20.19.0
Published on
Apr 03, 2025
Cumulative downloads
Total Downloads
Last Day
-1.9%
11,731,586
Compared to previous day
Last Week
-6.4%
71,526,078
Compared to previous week
Last Month
1.8%
313,153,082
Compared to previous month
Last Year
13.1%
3,389,747,756
Compared to previous year
An API for MIME type information.
[!Note]
mime@4
is nowlatest
. If you're upgrading frommime@3
, note the following:
mime@4
is API-compatible withmime@3
, withonetwo exceptions:
- Direct imports of
mime
properties no longer supportedmime.define()
cannot be called on the defaultmime
object- ESM module support is required. ESM Module FAQ.
- Requires an ES2020 or newer runtime
- Built-in Typescript types (
@types/mime
no longer needed)
1npm install mime
For the full version (800+ MIME types, 1,000+ extensions):
1import mime from 'mime'; 2 3mime.getType('txt'); // ⇨ 'text/plain' 4mime.getExtension('text/plain'); // ⇨ 'txt'
mime/lite
is a drop-in mime
replacement, stripped of unofficial ("prs.*
", "x-*
", "vnd.*
") types:
1import mime from 'mime/lite';
mime.getType(pathOrExtension)
Get mime type for the given file path or extension. E.g.
1mime.getType('js'); // ⇨ 'text/javascript' 2mime.getType('json'); // ⇨ 'application/json' 3 4mime.getType('txt'); // ⇨ 'text/plain' 5mime.getType('dir/text.txt'); // ⇨ 'text/plain' 6mime.getType('dir\\text.txt'); // ⇨ 'text/plain' 7mime.getType('.text.txt'); // ⇨ 'text/plain' 8mime.getType('.txt'); // ⇨ 'text/plain'
null
is returned in cases where an extension is not detected or recognized
1mime.getType('foo/txt'); // ⇨ null 2mime.getType('bogus_type'); // ⇨ null
mime.getExtension(type)
Get file extension for the given mime type. Charset options (often included in Content-Type headers) are ignored.
1mime.getExtension('text/plain'); // ⇨ 'txt' 2mime.getExtension('application/json'); // ⇨ 'json' 3mime.getExtension('text/html; charset=utf8'); // ⇨ 'html'
mime.getAllExtensions(type)
[!Note] New in
mime@4
Get all file extensions for the given mime type.
1mime.getAllExtensions('image/jpeg'); // ⇨ Set(3) { 'jpeg', 'jpg', 'jpe' }
Mime
instancesThe default mime
objects are immutable. Custom, mutable versions can be created as follows...
Create a new, custom mime instance. For example, to create a mutable version of the default mime
instance:
1import { Mime } from 'mime/lite'; 2 3import standardTypes from 'mime/types/standard.js'; 4import otherTypes from 'mime/types/other.js'; 5 6const mime = new Mime(standardTypes, otherTypes);
Each argument is passed to the define()
method, below. For example new Mime(standardTypes, otherTypes)
is synonomous with new Mime().define(standardTypes).define(otherTypes)
mime.define(type map [, force = false])
[!Note] Only available on custom
Mime
instances
Define MIME type -> extensions.
Attempting to map a type to an already-defined extension will throw
unless the force
argument is set to true
.
1mime.define({'text/x-abc': ['abc', 'abcd']}); 2 3mime.getType('abcd'); // ⇨ 'text/x-abc' 4mime.getExtension('text/x-abc') // ⇨ 'abc'
1$ mime scripts/jquery.js 2text/javascript
1$ mime -r image/jpeg 2jpeg
7.5/10
Summary
mime Regular Expression Denial of Service when MIME lookup performed on untrusted user input
Affected Versions
>= 2.0.0, < 2.0.3
Patched Versions
2.0.3
7.5/10
Summary
mime Regular Expression Denial of Service when MIME lookup performed on untrusted user input
Affected Versions
< 1.4.1
Patched Versions
1.4.1
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
0 existing vulnerabilities detected
Reason
9 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 9
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
Reason
Found 1/28 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-05-26
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 More