
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
node-mime-types
Advanced tools
A Node.js and zero-dependencies MIME type utility.
This library is powered by mime-db data. It provides a very simple, lightweight, safe yet speed utility to deal with MIME types and file extensions.
Supports 1180 file extensions and 965 MIME types.
npm install node-mime-types
npm i -S node-mime-types
Code style follows Airbnb JavaScript Best Practices using ESLint.
Uses Mocha and Chai for unit testing.
npm audit
.const mime = require('node-mime-types');
// mime is an object of functions
const {
getExtension,
getMIMEType,
} = require('node-mime-types');
node-mime-types module exports an object of functions. You'll find the complete list of functions below.
mime
<Object> with the following functions.Returns the file extension(s) based on the MIME type.
Note:
mimeType
<String>''
Examples:
getExtension(); // ''
getExtension(false); // ''
getExtension(''); // ''
getExtension('application/unknown'); // ''
getExtension('application/json5'); // '.json5'
getExtension('application/rtf'); // '.rtf'
getExtension('text/plain'); // ['.txt', '.text', '.conf', '.def', '.list', '.log', '.in', '.ini']
getExtension('application/json'); // ['.json', '.map']
getExtension('IMAGE/PNG'); // '.png'
Returns the MIME type based on the file name or path extension.
Note:
filenameOrPath
<String>application/octet-stream
Examples:
getMIMEType(); // ''
getMIMEType([]); // ''
getMIMEType(''); // ''
getMIMEType('f'); // 'application/octet-stream'
getMIMEType('file.unknown'); // 'application/octet-stream'
getMIMEType('.js'); // 'application/octet-stream'
getMIMEType('file.html'); // 'text/html'
getMIMEType('file.css'); // 'text/css'
getMIMEType('/usr/file.json'); // 'application/json'
getMIMEType('/usr/file.json.txt'); // 'text/plain'
getMIMEType('C:\\file.JS'); // 'application/javascript'
getMIMEType('../../path/to/file-name.XML'); // 'text/xml'
getMIMEType('README.md'); // 'text/markdown'
This project has a Code of Conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
If you find any MIME type or file extension missing, please directly contribute to mime-db.
Please take also a moment to read our Contributing Guidelines if you haven't yet done so.
Uses prettier
to format source code.
npm run format
npm run lint
npm run lint:fix
npm test
Extensions by MIME type and MIME types by extension files.
NOTE:
src
right after building files;npm run build
Please see our Support page if you have any questions or for any help needed.
For any security concerns or issues, please visit our Security Policy page.
MIT.
1.1.2 - delivery @07/06/2023
FAQs
A Node.js and zero-dependencies MIME type utility
The npm package node-mime-types receives a total of 2,666 weekly downloads. As such, node-mime-types popularity was classified as popular.
We found that node-mime-types demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.