Skip to main content
Home

Utility functions for media types (MIME types)

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
94%
Published
6 months ago (1.1.0)

Utility functions for media types (MIME types).

This API is inspired by the GoLang mime package and jshttp/mime-types, and is designed to integrate and improve the APIs from x/media_types.

The vendor folder contains copy of the jshttp/mime-db db.json file, along with its license.

import { contentType, allExtensions, getCharset } from "@std/media-types";
import { assertEquals } from "@std/assert";

assertEquals(allExtensions("application/json"), ["json", "map"]);

assertEquals(contentType(".json"), "application/json; charset=UTF-8");

assertEquals(getCharset("text/plain"), "UTF-8");

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/media-types

Import symbol

import * as media_types from "@std/media-types";
or

Import directly with a jsr specifier

import * as media_types from "jsr:@std/media-types";

Add Package

pnpm i jsr:@std/media-types
or (using pnpm 10.8 or older)
pnpm dlx jsr add @std/media-types

Import symbol

import * as media_types from "@std/media-types";

Add Package

yarn add jsr:@std/media-types
or (using Yarn 4.8 or older)
yarn dlx jsr add @std/media-types

Import symbol

import * as media_types from "@std/media-types";

Add Package

npx jsr add @std/media-types

Import symbol

import * as media_types from "@std/media-types";

Add Package

bunx jsr add @std/media-types

Import symbol

import * as media_types from "@std/media-types";