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 errorCommon MIME Types
| Extension | MIME Type | Constant |
|---|---|---|
| .html | text/html | HTML |
| .css | text/css | CSS |
| .js | application/javascript | JS |
| .json | application/json | JSON |
| .png | image/png | PNG |
| .jpg, .jpeg | image/jpeg | JPG/JPEG |
| .gif | image/gif | GIF |
| .svg | image/svg+xml | SVG |
| application/pdf | ||
| .mp4 | video/mp4 | MP4 |
| .mp3 | audio/mpeg | MP3 |
| .woff | font/woff | WOFF |
| .woff2 | font/woff2 | WOFF2 |
| .xml | application/xml | XML |
| .zip | application/zip | ZIP |