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/LICENSE3. Used by agents' projects
Dependency in 22 public GitHub projects set up for AI coding agents that we scanned (0.4%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
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
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
Often used with
More about mime-types
Funding
- Open Collective: https://opencollective.com/express
Alternatives
mime-types This page
Pick file-type when you must know what a file really is from its bytes, for example to block a renamed program in uploads.
Pick mime when your project uses ES modules and you want its getType and getExtension calls or the smaller mime/lite build.
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.”
Add the package to your Node.js project (Node.js 18 or newer for version 3).
npm install mime-typesLoad 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'
Mistakes to avoid
contentType() treats anything with a slash as a ready type and returns it unchanged; in our run 'folder/.htaccess' came back as the "type".
Unknown names give false, which is not a valid header value, and lookup() does not add charset=utf-8 for text.
getType and getExtension belong to the separate mime package; mime-types keeps the mime 1.x names.
extension() returns the first extension in mime-db's list; in our run audio/mpeg gave "mpga".
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.