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'
50 mime.lookup('cats') // false
53 ### mime.contentType(type)
55 Create a full content-type header given a content-type or extension.
58 mime.contentType('markdown') // 'text/x-markdown; charset=utf-8'
59 mime.contentType('file.json') // 'application/json; charset=utf-8'
62 ### mime.extension(type)
64 Get the default extension for a content-type.
67 mime.extension('application/octet-stream') // 'bin'
70 ### mime.charset(type)
72 Lookup the implied default charset of a content-type.
75 mime.charset('text/x-markdown') // 'UTF-8'
78 ### var type = mime.types[extension]
80 A map of content-types by extension.
82 ### [extensions...] = mime.extensions[type]
84 A map of extensions by content-type.
90 [npm-image]: https://img.shields.io/npm/v/mime-types.svg?style=flat
91 [npm-url]: https://npmjs.org/package/mime-types
92 [node-version-image]: https://img.shields.io/badge/node.js-%3E%3D_0.6-brightgreen.svg?style=flat
93 [node-version-url]: http://nodejs.org/download/
94 [travis-image]: https://img.shields.io/travis/jshttp/mime-types.svg?style=flat
95 [travis-url]: https://travis-ci.org/jshttp/mime-types
96 [coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-types.svg?style=flat
97 [coveralls-url]: https://coveralls.io/r/jshttp/mime-types
98 [downloads-image]: https://img.shields.io/npm/dm/mime-types.svg?style=flat
99 [downloads-url]: https://npmjs.org/package/mime-types