API Reference
mime-types
Utility to look up MIME types from file extensions and extensions from MIME types, with charset defaults.
Official Documentation ↗CompatibilityThis documentation covers version
v3.0.2. Check the official docs for the latest API surface.Installation
npm
npm install mime-typesMethods
No methods match this filter.
mime-types maps extensions to content types and back using the mime-db dataset.
Key Features
- Extension to MIME type lookup
- MIME type back to extension
- Content-Type with charset defaults
Usage Notes
Pin a version and check the official docs for the API surface you depend on before upgrading.
API reference evidence
Fetched from official sources on 2026-11-08T17:49:40+08:00 via WebFetch https://raw.githubusercontent.com/jshttp/mime-types/master/README.md.
mime.lookup→ signature from https://raw.githubusercontent.com/jshttp/mime-types/master/README.md; official text: “### mime.lookup(path) Lookup the content-type associated with a file.”mime.contentType→ signature from https://raw.githubusercontent.com/jshttp/mime-types/master/README.md; official text: “### mime.contentType(type) Create a full content-type header given a content-type or extension.”mime.extension→ signature from https://raw.githubusercontent.com/jshttp/mime-types/master/README.md; official text: “### mime.extension(type) Get the default extension for a content-type.”
FAQ
- What does a false return mean?
- false indicates no mapping exists for the input, so callers should fall back to application/octet-stream instead of assuming a type.
- Where does the data come from?
- The mime-db dataset, which aggregates IANA registrations and common community mappings.
- Does it detect encoding by content?
- No. It maps names and types only. Use a content sniffing library when you must detect the type from bytes.
Report a problem with this API docOpens a pre-filled issue on GitHub.