3 [![NPM Version][npm-image]][npm-url]
4 [![NPM Downloads][downloads-image]][downloads-url]
5 [![Node.js Version][node-version-image]][node-version-url]
6 [![Build Status][travis-image]][travis-url]
7 [![Test Coverage][coveralls-image]][coveralls-url]
9 The ultimate javascript content-type utility.
11 Similar to [node-mime](https://github.com/broofa/node-mime), except:
13 - __No fallbacks.__ Instead of naively returning the first available type, `mime-types` simply returns `false`,
14 so do `var type = mime.lookup('unrecognized') || 'application/octet-stream'`.
15 - No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`.
16 - Additional mime types are added such as jade and stylus via [mime-db](https://github.com/jshttp/mime-db)
17 - No `.define()` functionality
19 Otherwise, the API is compatible.
24 $ npm install mime-types
29 All mime types are based on [mime-db](https://github.com/jshttp/mime-db),
30 so open a PR there if you'd like to add mime types.
35 var mime = require('mime-types')
38 All functions return `false` if input is invalid or not found.
42 Lookup the content-type associated with a file.
45 mime.lookup('json') // 'application/json'
46 mime.lookup('.md') // 'text/x-markdown'
47 mime.lookup('file.html') // 'text/html'
48 mime.lookup('folder/file.js') // 'application/javascript'
49 mime.lookup('folder/.htaccess') // false
51 mime.lookup('cats') // false
54 ### mime.contentType(type)
56 Create a full content-type header given a content-type or extension.
59 mime.contentType('markdown') // 'text/x-markdown; charset=utf-8'
60 mime.contentType('file.json') // 'application/json; charset=utf-8'
63 mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8'
66 ### mime.extension(type)
68 Get the default extension for a content-type.
71 mime.extension('application/octet-stream') // 'bin'
74 ### mime.charset(type)
76 Lookup the implied default charset of a content-type.
79 mime.charset('text/x-markdown') // 'UTF-8'
82 ### var type = mime.types[extension]
84 A map of content-types by extension.
86 ### [extensions...] = mime.extensions[type]
88 A map of extensions by content-type.
94 [npm-image]: https://img.shields.io/npm/v/mime-types.svg
95 [npm-url]: https://npmjs.org/package/mime-types
96 [node-version-image]: https://img.shields.io/node/v/mime-types.svg
97 [node-version-url]: https://nodejs.org/en/download/
98 [travis-image]: https://img.shields.io/travis/jshttp/mime-types/master.svg
99 [travis-url]: https://travis-ci.org/jshttp/mime-types
100 [coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-types/master.svg
101 [coveralls-url]: https://coveralls.io/r/jshttp/mime-types
102 [downloads-image]: https://img.shields.io/npm/dm/mime-types.svg
103 [downloads-url]: https://npmjs.org/package/mime-types