mime-types

Comprehensive MIME type lookup library for Node.js. Maps file extensions to MIME types (lookup) and MIME types to extensions (extension). Used in web servers, file upload handlers, and HTTP agents to set correct Content-Type headers and validate file extensions. Minimal, no-dependency library based on the mime-db database of 1000+ types.

Evaluated Mar 06, 2026 (0d ago) v2.x
Homepage ↗ Repo ↗ Developer Tools mime content-type http node file-type extension lookup minimal
⚙ Agent Friendliness
71
/ 100
Can an agent use this?
🔒 Security
98
/ 100
Is it safe for agents?
⚡ Reliability
96
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

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

🔒 Security

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

Zero dependencies. Read-only lookup — no side effects. Extension-based MIME detection should be combined with file-type content detection for security-critical file validation.

⚡ Reliability

Uptime/SLA
100
Version Stability
95
Breaking Changes
95
Error Recovery
95
AF Security Reliability

Best When

You need fast, zero-dependency extension-to-MIME mapping in Node.js HTTP handlers or file processing pipelines.

Avoid When

You need to detect file type from binary content (use file-type) or register custom MIME types (use mime npm package).

Use Cases

  • Set correct Content-Type headers when serving files in agent HTTP servers — lookup('.pdf') returns 'application/pdf'
  • Validate uploaded file extensions against expected MIME types in agent file upload processing
  • Determine file extension from Content-Type response headers in agent HTTP clients downloading files from APIs
  • Generate correct Accept headers in agent HTTP requests when fetching specific file types from external APIs
  • Build file routing logic in agent pipelines based on MIME type — route images, PDFs, and CSVs to different processors

Not For

  • Detecting actual file type from binary content — use file-type for magic byte detection; mime-types only does extension-to-MIME mapping
  • Custom/proprietary MIME types — mime-types uses a fixed database; use the mime package for custom type registration
  • Browser environments — browsers have native MIME type handling; mime-types is for Node.js server-side use

Interface

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

Authentication

Methods: none
OAuth: No Scopes: No

No authentication — local lookup table library.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

mime-types is open source and free.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • mime.lookup() returns false for unknown extensions (not null, not undefined) — check if (mimeType) before using; comparison with false is required
  • mime.contentType('.html') returns 'text/html; charset=utf-8' with charset — strip charset for raw MIME type comparisons using .split(';')[0]
  • mime.extension() returns the most common extension for a MIME type — 'image/jpeg' returns 'jpeg' not 'jpg'; normalize if specific extension is required
  • mime-types doesn't support custom type registration — use the mime package (mime.define()) if you need to add proprietary MIME types
  • Some multi-extension types return different results — 'application/x-www-form-urlencoded' has no extension; always check for false return value
  • MIME database updates require package updates — new file formats won't be recognized until mime-db is updated; check mime-db version for coverage

Alternatives

Full Evaluation Report

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

$99

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

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