Mime DB

mime-db. This is a database of all mime types. If you're crazy enough to use this in the browser, you can just grab the JSON file using jsDelivr. npm jsDelivr

It aggregates data from the following sources:

Mozilla Developer Network offers a subset of mime types that are relevant to web browsers.

On 2021-10-30, we saved a copy of MDN's html page in our assets as common-types.html. Below we parse the HTML into an array of file suffix to media type pairs.

const idx = [] const parser = new DOMParser() const url = "/assets/pages/mime-db/common-types.html" const html = await fetch(url).then(res => res.text()) const doc = parser.parseFromString(html, "text/html") const codes = doc .querySelectorAll("table tr td:nth-child(1) code") for (let code of codes) { let ext = code.textContent.trim() let mime = code.closest("tr") .querySelector("td:nth-child(3) code") .textContent.trim() idx.push([ext, mime]) } export default idx

In the frame below we can view the results.

//wiki.dbbs.co/assets/pages/js-snippet-template/importjs.html

pages/mime-db