MIME type consistency

Usage no npm install needed!

<script type="module">
  import shopifyMimeTypes from 'https://cdn.skypack.dev/@shopify/mime-types';



Build Status Build Status License: MIT npm version npm bundle size (minified + gzip)

MIME type consistency.


$ yarn add @shopify/mime-types


This package exposes utilities to dynamically get MIME types from file names and/or get file extensions based on common MIME types.

The types of files currently supported are:


This helps keeping MIME types and file extensions consistent.


Takes in a file name string and returns a MimeType.

import {getMimeTypeFromFilename} from '@shopify/mime-types';

getMimeTypeFromFilename('image.jpg'); // image/jpeg


Takes in a MimeType and returns a string filename extension that matches the inputted MimeType.

import {getExtensionFromMimeType, MimeType} from '@shopify/mime-types';

getExtensionFromMimeType(MimeType.Pdf); // .pdf