mime-types

The ultimate JavaScript content-type utility for resolving MIME types from file extensions and paths.

Library
npm
v3.0.2
1,472stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
52/100Fair
Development Activity20
Maintenance32
Community68
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
82/100Excellent
Architecture78
Code Quality82
Innovation88
Learning Curve90

mime-types is a small, dependency-light Node.js utility that maps between file extensions and MIME content types. Built on top of the canonical mime-db dataset, it lets you look up the content type for a path, build a complete Content-Type header with the right charset, and find the default extension for a given type.

Unlike naive alternatives, it never guesses: every function returns false for unknown or invalid input, so you stay in full control of fallbacks. Its tiny, function-based API has made it a foundational building block across the Node.js ecosystem, powering frameworks like Express and countless file-serving and upload pipelines.

What You Get

  • Extension-to-MIME lookup via mime.lookup(path) that accepts bare extensions, dotted extensions, or full file paths
  • Full Content-Type header construction with mime.contentType(type), automatically appending the correct charset
  • Reverse mime.extension(type) lookup to get the default file extension for any MIME type
  • Charset resolution with mime.charset(type) plus direct mime.types and mime.extensions maps for custom logic

Common Use Cases

  • Setting the correct Content-Type response header when serving static files from a Node.js server
  • Validating and labelling uploaded files by mapping their extension to an expected MIME type
  • Choosing a sensible file extension when saving a downloaded resource identified only by its content type

Under The Hood

Architecture - The entire library lives in a single index.js that, at load time, calls populateMaps() to iterate every entry in the mime-db database and build two lookup tables on the exported object: types (extension to MIME type) and extensions (MIME type to extension list). Public functions lookup, contentType, extension, and charset are thin readers over these maps, with lookup normalizing input via Node’s path.extname('x.' + path) trick and a shared EXTRACT_TYPE_REGEXP stripping parameters from content types. When two types claim the same extension, _preferredType() in mimeScore.js resolves the conflict deterministically.

Tech Stack - Plain CommonJS JavaScript targeting Node.js >= 18 with a single runtime dependency, mime-db (^1.54.0), which supplies the underlying type data. mimeScore.js is a back-ported, dependency-free scoring function. Development tooling uses Mocha and nyc for tests and coverage, and ESLint with the Standard config for linting; there is no build step or transpilation.

Code Quality - The codebase is small, readable, and thoroughly covered by a 247-line Mocha suite in test/test.js exercising every public function across valid, invalid, and edge-case inputs. Input guards consistently reject non-string arguments by returning false, and functions are documented with JSDoc annotations. A small amount of transitional legacy code (_preferredTypeLegacy, _extensionConflicts) remains from a scoring migration.

API Design - The public surface is intentionally minimal: four functions plus two data maps, all destructurable directly from the module because nothing is stateful or class-based. Every function follows the same contract of returning false on failure, which makes fallback handling explicit and predictable. The API is deliberately compatible with the older mime@1.x module while removing its implicit fallbacks, and the README documents each function with concrete examples.

Used by 39 apps in this directory

TypeScript
99%
Other

Activepieces

Automation · AI Assistants

23,887

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
65
Dependency
Built with
TypeScript99%
Updated today
TypeScript
88%
Other

AFFiNE

Productivity · Project Management · Note Taking

71,668

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript88%
Updated today
TypeScript
72%
AGPL 3.0

APITable

Low Code Platforms · Databases

15,526

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
53
Repo Health
77
Technical
60
Dependency
Built with
TypeScript72%
Java22%
Updated 9 months ago
TypeScript
89%
Other

anytype-ts

Knowledge Management · Note Taking · Collaboration

8,665

A local-first, end-to-end encrypted knowledge OS that lets you build notes, tasks, wikis, and entire apps — with your data stored offline and synced peer-to-peer.

View details
88
Repo Health
78
Technical
67
Dependency
Built with
TypeScript89%
Updated yesterday
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,846

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
99%
AGPL 3.0

Cherry Studio

AI Assistants

50,753

All-in-one AI desktop client with 300+ assistants and multi-model support

View details
88
Repo Health
84
Technical
71
Dependency
Built with
TypeScript99%
Updated today
TypeScript
80%
Other

Directus

CMS · Low Code Platforms

37,462

Connect any SQL database and get instant REST and GraphQL APIs, a visual management Studio, and a native MCP server for AI agents — free for most organizations.

View details
93
Repo Health
82
Technical
78
Dependency
Built with
TypeScript80%
Vue18%
Updated yesterday
TypeScript
95%
AGPL 3.0

Docmost

Productivity · Note Taking · Collaboration

21,411

Self-hosted collaborative wiki and knowledge base with real-time editing, diagrams, AI assistance, and enterprise access controls — a modern alternative to Confluence and Notion.

View details
89
Repo Health
70
Technical
71
Dependency
Built with
TypeScript95%
Updated yesterday
Java
34%
Apache 2.0

Enso

Analytics · Data Engineering · Low Code Platforms

7,437

A visual and textual programming platform for data prep and analysis where the node graph and the underlying Enso code are always perfectly in sync, built by an Alteryx co-founder on a GraalVM engine.

View details
70
Repo Health
90
Technical
62
Dependency
Built with
Java34%
TypeScript27%
Scala26%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search