Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 3 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

mime-types

The right file type for any file name.

UtilitiesNPM

GitHubWebsite

1. License

“Permission is hereby granted, free of charge, to any person obtaining a copy of this software”

Paid and closed-source products may use it; no fee and no on-screen credit needed.

github.com/jshttp/mime-types/blob/master/LICENSE

From the package registry and GitHub, checked daily; card checked Nov 10, 2026. Tap a verdict to see its source.How we checkedReport an error

What mime-types does

mime-types is a small free JavaScript package for Node.js servers. Give it a file name like report.pdf and it returns the type label browsers expect, such as application/pdf, or the other way round. Your server then sends files that open in the browser instead of downloading as unknown data.

What people build with it

Serve files with the right type

Your app sends uploaded files or generated reports from its own route; each one gets the matching Content-Type header, so a PDF opens in the browser tab.

Accept only pictures in an upload form Idea

Before saving an avatar, check that the file name ends in a picture type you allow and reject the others with a clear message.

Name files you download

Your app fetches a file from another service and only knows its type; mime-types gives the extension to save it under, such as .png or .pdf.

A safe default for unknown files

Files with no or a strange extension get the generic binary type, so browsers download them instead of guessing.

Mark text files as UTF-8

Markdown, CSV and other text files get charset=utf-8 added to their type, so accents and emoji show correctly.

Set the type on cloud storage uploads Idea

When your app puts files into cloud storage, pass the looked-up type along, so the public link opens a picture instead of downloading it.

mime-types popularity

62 / 100
Gid Score, #907 overall
414M
downloads a week, npm
1,480
GitHub stars
22
agent projects use it
mime-types: downloads per weeknpm, mime-types 414,101,665
mime-types: GitHub starsjshttp/mime-types 1,480

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How mime-types is used

  • mime-types is a dependency in 22 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (0.5% of the 4,867 JavaScript/TypeScript ones), #69 of 408 in utilities.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 73; those are left out of every share on this page.
  • Projects that use it most often also use esbuild (50.0%), date-fns (45.5%), cross-env (36.4%).

By coding agent

13 projects, 0.4%
11 projects, 0.5%
6 projects, 0.2%
5 projects, 1.1%

Often used with

In 50.0% of its projects
In 45.5% of its projects
In 36.4% of its projects
In 36.4% of its projects
In 36.4% of its projects
In 90.9% of its projects
In 54.5% of its projects
In 59.1% of its projects

More about mime-types

Funding
  • Open Collective: https://opencollective.com/express

See all

More in Utilities

Alternatives

mime-types This page

MITGid 62414M/wk

file-type

Pick file-type when you must know what a file really is from its bytes, for example to block a renamed program in uploads.

mime

Pick mime when your project uses ES modules and you want its getType and getExtension calls or the smaller mime/lite build.

Compare mime-types with another tool

Get started

Tell your AI assistant

“Use the npm package mime-types (pin mime-types@3.0.2, Node.js 18+) to set the Content-Type header for files my server sends, with mime.contentType(path.extname(file)) and application/octet-stream when it returns false.”

  1. Add the package to your Node.js project (Node.js 18 or newer for version 3).

    npm install mime-types

    From github.com/jshttp/mime-types/blob/master/README.md

  2. Load it and look up types by file name or extension.

    var mime = require('mime-types')
    mime.lookup('file.html') // 'text/html'
    mime.contentType('file.json') // 'application/json; charset=utf-8'
    

    From github.com/jshttp/mime-types/blob/master/README.md

Mistakes to avoid

mime.contentType('uploads/report.pdf') or any value that contains a slash
mime.contentType(path.extname(file)) or mime.lookup(file)

contentType() treats anything with a slash as a ready type and returns it unchanged; in our run 'folder/.htaccess' came back as the "type".

res.setHeader('Content-Type', mime.lookup(name))
res.setHeader('Content-Type', mime.contentType(path.extname(name)) || 'application/octet-stream')

Unknown names give false, which is not a valid header value, and lookup() does not add charset=utf-8 for text.

mime.getType(name) or mime.getExtension(type)
mime.lookup(name) and mime.extension(type)

getType and getExtension belong to the separate mime package; mime-types keeps the mime 1.x names.

Naming an MP3 download with mime.extension('audio/mpeg')
Keep a small map for the types you care about (audio/mpeg -> mp3) and fall back to mime.extension()

extension() returns the first extension in mime-db's list; in our run audio/mpeg gave "mpga".

Expecting the same answers after upgrading from 2.x (for example text/xml for .xml)
Re-check the types your app depends on after an upgrade to 3.x

Version 3.0.0 changed several answers to settle conflicts between sources.

Questions

Does it check what is inside the file?

No. It looks only at the extension in the name; for real content checks use a package that reads the file's first bytes, such as file-type.

What does it return for a file it does not know?

false. Add your own fallback, usually application/octet-stream.

Where do the types come from?

From mime-db, a list built from the official IANA register and the Apache and nginx web server lists.

Is it the same as the mime package?

No. Its calls match the old mime 1.x style (lookup, extension), not mime's newer getType and getExtension.

Can I use it in a paid app?

Yes. It is MIT licensed; keep the license notice when you ship its files.