talira

mime (npm)

MIME type lookup for JavaScript, by extension or type

open sourceMITfree

mime is a JavaScript API for MIME type information covering every type in mime-db: look up a type by file extension (getType('txt')) or an extension by type (getExtension('text/plain')), and define custom mappings. It ships TypeScript types, and mime/lite is a smaller drop-in without unofficial vendor and experimental types. Version 4 is ESM-only. It's by Robert Kieffer.

Problems it solves

  • get the MIME type for a file extension in JavaScript
  • set the Content-Type header from a filename in Node
  • find the file extension for a MIME type in JavaScript

Features

  • all mime-db types
  • type from extension and extension from type
  • custom type definitions
  • built-in TypeScript types
  • mime/lite without unofficial types