node package manager
Stop wasting time. Easily manage code sharing in your team. Create a free org »


MIM Build Status NPM version Code Climate

A simple MIME type recognition library that works in both browser and Node.js apps



Install MIM with npm:

npm install mim

And then require it in your node app:

var MIM = require('mim');


Install MIM with bower:

bower install mim

Or download desired version from on the Releases page

Then add the HTML script tag to include MIM in your global Javascript namespace:

<script src="wherever/mim.js"></script>


MIME type lookup

var mimeType;
mimeType = MIM.getMIMEType('nonexistent');
console.log(mimeType); // displays null 
mimeType = MIM.getMIMEType('mkv');
console.log(mimeType); // displays 'video/x-matroska' 
mimeType = MIM.getMIMEType('.jpeg');
console.log(mimeType); // displays 'image/jpeg' 
mimeType = MIM.getMIMEType('long_file-name.ecma');
console.log(mimeType); // displays 'application/ecmascript' 
mimeType = MIM.getMIMEType('/etc/default/whatever.mif');
console.log(mimeType); // displays 'application/vnd.mif' 
mimeType = MIM.getMIMEType('/folder with spaces/and file with space.xspf');
console.log(mimeType); // displays 'application/xspf+xml' 
mimeType = MIM.getMIMEType('../../');
console.log(mimeType); // displays 'chemical/x-xyz' 
mimeType = MIM.getMIMEType('');
console.log(mimeType); // displays 'application/json' 
mimeType = MIM.getMIMEType('');
console.log(mimeType); // displays 'application/zip' 

MIME type lookup with default

var mimeType;
mimeType = MIM.getMIMEType('nonexistent', 'application/octet-stream');
console.log(mimeType); // displays 'application/octet-stream' 


MIM is released under the MIT License.