MIME Type Names Database

1.0.0 · active · verified Wed Apr 22

mime-names is a JavaScript package that provides a database of human-readable names and common file extensions, keyed by MIME types. It is designed to complement `mime-db`, offering a more descriptive layer on top of MIME type definitions. This package does not aim to be an exhaustive list of all MIME types, focusing instead on popular and commonly used formats. Developers should anticipate that some less common MIME types might not be present and implement graceful handling for such cases. The current stable version is 1.0.0, and releases are typically made as needed to add new types or update existing data. Its primary differentiator is its direct, lookup-table structure and its specific focus on human-readable names and extensions rather than broader MIME type resolution logic.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to import the MIME database and look up information for a specific MIME type, including handling cases where a type might not be found. It illustrates accessing the name and extensions properties.

import db from 'mime-names';

const mimeType = 'application/json';
const data = db[mimeType];

if (data) {
  console.log(`MIME Type: ${mimeType}`);
  console.log(`  Name: ${data.name}`);
  console.log(`  Extensions: ${data.extensions ? data.extensions.join(', ') : 'None'}`);
} else {
  console.log(`No data found for MIME type: ${mimeType}`);
}

const unknownMimeType = 'application/x-custom-type';
const unknownData = db[unknownMimeType];
if (!unknownData) {
  console.log(`\nAs expected, no data for ${unknownMimeType} (not all-encompassing).`);
}

view raw JSON →