Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mime-types

Package Overview
Dependencies
Maintainers
2
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mime-types

The ultimate javascript content-type utility.

  • 2.1.28
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
54M
decreased by-8.16%
Maintainers
2
Weekly downloads
 
Created

What is mime-types?

The mime-types npm package is a utility for resolving file extensions to MIME types and vice versa. It is based on the mime-db dataset, which is a comprehensive set of MIME type definitions.

What are mime-types's main functionalities?

Lookup MIME type for a file extension

This feature allows you to find the MIME type for a given file extension. If the extension has a MIME type in the database, it will return it as a string; otherwise, it will return false.

const mime = require('mime-types');
const mimeType = mime.lookup('json'); // 'application/json'

Determine the default extension for a MIME type

This feature enables you to find the default file extension for a given MIME type. If the MIME type has an associated extension, it will return it as a string; otherwise, it will return false.

const mime = require('mime-types');
const extension = mime.extension('application/json'); // 'json'

Lookup charset for a MIME type

This feature allows you to find the default charset for a given MIME type, which can be useful when setting the 'Content-Type' header in HTTP responses.

const mime = require('mime-types');
const charset = mime.charset('text/markdown'); // 'UTF-8'

Content-Type parsing

This feature is used to build a full Content-Type header given a MIME type or extension. It will also append the charset parameter when appropriate.

const mime = require('mime-types');
const contentType = mime.contentType('markdown'); // 'text/markdown; charset=utf-8'

Other packages similar to mime-types

Keywords

FAQs

Package last updated on 02 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc