Interactive Playground

Try mime-types-lite directly in your browser

MIME Type Lookup
Enter a file path or extension to get its MIME type
Try:

How it works

Example Usagetypescript
import mimeTypesLite from 'mime-types-lite';

// Create extension mapping
const extensionMap: Record<string, string> = {
  'html': mimeTypesLite.HTML,
  'css': mimeTypesLite.CSS,
  'js': mimeTypesLite.JS,
  'png': mimeTypesLite.PNG,
  'pdf': mimeTypesLite.PDF,
};

// Lookup function
function getMimeType(extension: string): string | undefined {
  return extensionMap[extension.toLowerCase()];
}

getMimeType('html');  // 'text/html'
getMimeType('PNG');   // 'image/png'

API Reference

Default Export

Import the MIME types object

import mimeTypesLite from 'mime-types-lite';

console.log(mimeTypesLite.HTML);
// → 'text/html'

console.log(mimeTypesLite.PNG);
// → 'image/png'

TypeScript Type

Type-safe MIME type references

import { type MimeType } from 'mime-types-lite';

const types: MimeType[] = [
  'HTML',
  'CSS',
  'PNG',
  'JPEG',
];

// TypeScript will error for invalid types
const invalid: MimeType = 'INVALID'; 
// ❌ Type error

Common MIME Types

ExtensionMIME TypeConstant
.htmltext/htmlHTML
.csstext/cssCSS
.jsapplication/javascriptJS
.jsonapplication/jsonJSON
.pngimage/pngPNG
.jpg, .jpegimage/jpegJPG/JPEG
.gifimage/gifGIF
.svgimage/svg+xmlSVG
.pdfapplication/pdfPDF
.mp4video/mp4MP4
.mp3audio/mpegMP3
.wofffont/woffWOFF
.woff2font/woff2WOFF2
.xmlapplication/xmlXML
.zipapplication/zipZIP