mime

Lightweight MIME type detection library for Node.js and browsers. Maps file extensions to MIME types (e.g., '.js' → 'text/javascript', '.png' → 'image/png') and vice versa. Implements the MIME Database (mime-db) with comprehensive type coverage. Two variants: mime (full database, larger) and mime/lite (smaller subset). The standard library for Content-Type header determination when serving files or handling uploads in Node.js HTTP servers.

Evaluated Mar 06, 2026 (0d ago) v4.x
Homepage ↗ Repo ↗ Developer Tools mime content-type file-types http node browser typescript
⚙ Agent Friendliness
70
/ 100
Can an agent use this?
🔒 Security
99
/ 100
Is it safe for agents?
⚡ Reliability
93
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
92
Error Messages
85
Auth Simplicity
100
Rate Limits
100

🔒 Security

TLS Enforcement
100
Auth Strength
100
Scope Granularity
100
Dep. Hygiene
95
Secret Handling
100

Extension-based MIME detection only — not a security tool. Do not rely on MIME type for security decisions without content-based validation.

⚡ Reliability

Uptime/SLA
98
Version Stability
90
Breaking Changes
85
Error Recovery
98
AF Security Reliability

Best When

You need quick, reliable MIME type lookup by file extension for Content-Type headers in Node.js HTTP servers or file handling code.

Avoid When

You need to detect MIME type from file content (magic bytes) rather than extension — use the file-type library for content-based detection.

Use Cases

  • Determine Content-Type headers when serving static files from a Node.js server based on file extension
  • Validate that uploaded file extensions match their claimed MIME type for file upload security
  • Look up file extensions for a MIME type when generating downloadable content with correct browser handling
  • Classify uploaded files by type (image, video, document) for storage organization or processing routing
  • Generate appropriate Content-Disposition headers for file downloads by detecting MIME type from filename

Not For

  • Magic number MIME detection from file content — mime uses extension-based detection only; use file-type for content-based detection
  • Complete MIME type validation for security — extension-to-MIME mapping can be spoofed; use file-type for genuine content validation
  • Very large file type databases — mime-db is comprehensive but use specialized libraries for exotic formats

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

No authentication — lookup utility library.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

Fully free, MIT licensed.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • mime v4 is ESM-only — use mime v3 for CommonJS or the mime-types package (which is CJS-compatible)
  • Unknown extensions return undefined — always null-check and provide a fallback: mime.getType('.xyz') ?? 'application/octet-stream'
  • MIME type lookup is extension-based not content-based — attackers can rename a .exe to .jpg; use file-type for security-sensitive upload validation
  • mime and mime-types are different packages — mime-types includes .lookup() and .contentType() with charset support; choose based on your needs
  • Custom MIME types can be defined with mime.define() — but these are per-instance and must be re-registered on each import
  • Not all MIME types have standard extensions — mime.getExtension('application/json') returns 'json', but some MIME types have no registered extension

Alternatives

Full Evaluation Report

Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for mime.

$99

Scores are editorial opinions as of 2026-03-06.

5215
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered