mime-types-lite
v1.9.0zero dependencies · Node 20+

Know what
you’re sending.

A small, reviewed vocabulary of MIME constants and practical helpers for headers, uploads, URLs, and file extensions.

Live route# 01
fromExtension( )text/javascriptmatches text/*

Filename lookup · no byte inspection

0runtime dependencies
Typedliteral unions included
Curatedcommon types, not a database
Universalserver and browser ready

Install / package manager

One package.
Use your tool.

Type declarations ship with the package. There is nothing else to configure.

$npm install mime-types-lite

The useful middle

More than constants.
Less than a database.

Resolve a filename, clean a real Content-Type header, or test a category wildcard with functions that compose.

Find a type from a path

Accepts extensions, filenames, Windows paths, and URLs with query strings.

fromExtension('reports/annual.pdf')
// 'application/pdf'

fromExtension('PHOTO.JPEG')
// 'image/jpeg'
from-extension

Normalize headers

Remove parameters, trim whitespace, lowercase, and validate.

normalizeMimeType(
  ' Application/JSON; charset=utf-8 '
)
// 'application/json'
normalize

Match the category

Test exact media types, category wildcards, or the universal wildcard.

matchesMimeType(
  'image/avif',
  'image/*'
)
// true
matching

Standards first

The modern answer,
with the old one nearby.

Current standards are the defaults. Historical values remain in LEGACY_MIME when interoperability requires them.

JavaScripttext/javascript
YAMLapplication/yaml
Iconimage/vnd.microsoft.icon
View standards and aliases →

A useful boundary

A MIME type is a label, not proof.

Extensions and Content-Type headers can be attacker-controlled. Inspect signatures and enforce limits for untrusted uploads.

Security notes →