{"id":28316246,"url":"https://github.com/somajitdey/mime-db-cdn","last_synced_at":"2026-03-16T20:01:41.870Z","repository":{"id":293495913,"uuid":"984235754","full_name":"SomajitDey/mime-db-cdn","owner":"SomajitDey","description":"A mime-db equivalent to serve data for each entry separately over CDN. Enables small, selective download for any given query.","archived":false,"fork":false,"pushed_at":"2025-05-27T11:05:17.000Z","size":530,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-01T11:53:47.365Z","etag":null,"topics":["browser","cdn","client-side","content-delivery-network","content-type","extension","file","file-extension","file-type","filesystem-database","frontend","jsdelivr","json","key-value-database","media-type","mime","mime-database","mime-db","mime-type","mimetypes"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/mime-db-cdn","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SomajitDey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-15T15:50:34.000Z","updated_at":"2025-05-27T11:05:01.000Z","dependencies_parsed_at":"2025-05-16T07:35:10.500Z","dependency_job_id":null,"html_url":"https://github.com/SomajitDey/mime-db-cdn","commit_stats":null,"previous_names":["somajitdey/mime-db","somajitdey/mime-db-cdn"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/SomajitDey/mime-db-cdn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SomajitDey%2Fmime-db-cdn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SomajitDey%2Fmime-db-cdn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SomajitDey%2Fmime-db-cdn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SomajitDey%2Fmime-db-cdn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SomajitDey","download_url":"https://codeload.github.com/SomajitDey/mime-db-cdn/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SomajitDey%2Fmime-db-cdn/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261542546,"owners_count":23174599,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser","cdn","client-side","content-delivery-network","content-type","extension","file","file-extension","file-type","filesystem-database","frontend","jsdelivr","json","key-value-database","media-type","mime","mime-database","mime-db","mime-type","mimetypes"],"created_at":"2025-05-25T02:11:12.639Z","updated_at":"2026-03-16T20:01:36.827Z","avatar_url":"https://github.com/SomajitDey.png","language":"JavaScript","funding_links":["https://buymeacoffee.com/SomajitDey"],"categories":[],"sub_categories":[],"readme":"# 💁 mime-db-cdn\n[![NPM Version](https://img.shields.io/npm/v/mime-db-cdn)](https://www.npmjs.com/package/mime-db-cdn)\n[![Build](https://github.com/SomajitDey/mime-db-cdn/actions/workflows/build.yaml/badge.svg)](https://github.com/SomajitDey/mime-db-cdn/actions/workflows/build.yaml)\n[![Test](https://github.com/SomajitDey/mime-db-cdn/actions/workflows/test.yaml/badge.svg)](https://github.com/SomajitDey/mime-db-cdn/actions/workflows/test.yaml)\n[![Publish NPM package](https://github.com/SomajitDey/mime-db-cdn/actions/workflows/publish.yaml/badge.svg)](https://github.com/SomajitDey/mime-db-cdn/actions/workflows/publish.yaml)\n\n🚀 A [mime-db](https://github.com/jshttp/mime-db) equivalent that lets you download just the data you need via multiple [CDNs](#usage). Unlike mime-db, one no more needs to download the [entire database file](https://github.com/jshttp/mime-db/blob/v1.54.0/db.json) at once.\n\n🚀 Mirrors the complete mime-db database, including the unofficial MIME-types (`prs.*`, `x-*`, `vnd.*`).\n\n🚀 Additionally includes `file-extension =\u003e MIME-type(s)` reverse lookup data, with the MIME-types [sorted in descending order of importance](https://github.com/jshttp/mime-types/issues/116).\n\n🚀 Also offers a portable JavaScript [SDK](#javascript-sdk) (ESM) to access the database through [dynamic import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import)s, providing memory-efficiency for both browsers and server-side runtimes.\n\n## Motivation\n[mime-db](https://github.com/jshttp/mime-db) packages the entire MIME-types database into a [JSON file](https://github.com/jshttp/mime-db/blob/v1.54.0/db.json). Using `mime-db` directly, therefore, entails downloading the entire database at once, albeit from a CDN. If you just need to query a handful of MIME-types or file-extensions, downloading the entire database followed by loading and retaining it in memory would be an overkill. This problem persists with popular packages based on `mime-db`, such as [mime](https://www.npmjs.com/package/mime) or [mime-types](https://www.npmjs.com/package/mime-types), which, in order to function, must first store the entire database locally on the user's machine.\n\nThe current project solves this problem by fragmenting `mime-db` into tiny JSON files, each storing data only for one of the available MIME-types or file-extensions. To understand the file-structure, explore the directories in the [database branch](https://github.com/SomajitDey/mime-db-cdn/tree/database). Each of these JSON files is readily downloadable using any of the free CDNs that serve GitHub or npm contents, e.g.\n- [jsdelivr](https://www.jsdelivr.com/?docs=gh)\n- [statically](https://github.com/staticallyio/statically)\n- [raw.githack](https://raw.githack.com/)\n- [unpkg](https://www.unpkg.com/)\n\n## Usage\nThis section presents CDN links to download just the desired data from our MIME-types database using any HTTP client, e.g. \n- any browser,\n- `curl` or `wget` in Linux,\n- the `Fetch API` in JavaScript etc..\n\n👉 For the JS-SDK usage, see the [SDK](#javascript-sdk) section below.\n\n👉 `\u003cref\u003e` below refers to either\n- `database`, i.e. the [database branch](https://github.com/SomajitDey/mime-db-cdn/tree/database), or\n- `\u003ctag\u003e`, i.e. any of the tags listed [here](https://github.com/SomajitDey/mime-db-cdn/tags), latest being the topmost one. See [versioning](#versioning) for more details.\n\n👉 For simplicity, only 2 CDNs (jsdelivr and unpkg) are explicitly mentioned. It is trivial to construct similar URLs for other available CDNs.\n\n### MIME-type to file-extension(s)\nDownload as JSON:\n\nFrom jsdelivr,\n```\nhttps://cdn.jsdelivr.net/gh/somajitdey/mime-db-cdn@\u003cref\u003e/mime-types/\u003cmime-type\u003e/data.json\n```\n\n```\nhttps://cdn.jsdelivr.net/npm/mime-db-cdn@\u003ctag\u003e/mime-types/\u003cmime-type\u003e/data.json\n```\n\nFrom unpkg,\n```\nhttps://unpkg.com/mime-db-cdn@\u003ctag\u003e/mime-types/\u003cmime-type\u003e/data.json\n```\n\nAbove, replace `\u003cmime-type\u003e` with your chosen MIME-type e.g. `image/jpeg`.\n\n👉 Apart from an `extensions` array, the JSON for a MIME-type also contains [these relevant data](https://github.com/jshttp/mime-db#data-structure). See [examples](#examples) below.\n\n### File-extension to MIME-type(s)\nDownload as JSON:\n\nFrom jsdelivr,\n```\nhttps://cdn.jsdelivr.net/gh/somajitdey/mime-db-cdn@\u003cref\u003e/extensions/\u003cextension\u003e/data.json\n```\n\n```\nhttps://cdn.jsdelivr.net/npm/mime-db-cdn@\u003ctag\u003e/extensions/\u003cextension\u003e/data.json\n```\n\nFrom unpkg,\n```\nhttps://unpkg.com/mime-db-cdn@\u003ctag\u003e/extensions/\u003cextension\u003e/data.json\n```\n\nAbove, replace `\u003cextension\u003e` with your chosen extension e.g. `jpg`.\n\n👉 The JSON contains an array of `mimeTypes`. **Note that this array of MIME-types is sorted in descending order of importance** according to the same [logic](https://github.com/jshttp/mime-types/blob/v3.0.1/mimeScore.js) used by [mime-types](https://github.com/jshttp/mime-types). See [examples](#examples) below. If only one MIME-type is required, simply choose the first element from the array!\n\n### Content-Type HTTP header\n\nFrom jsdelivr,\n```\nhttps://cdn.jsdelivr.net/gh/somajitdey/mime-db-cdn@\u003cref\u003e/file-types/type.\u003cextension\u003e\n```\n\n```\nhttps://cdn.jsdelivr.net/npm/mime-db-cdn@\u003ctag\u003e/file-types/type.\u003cextension\u003e\n```\n\nFrom unpkg,\n```\nhttps://unpkg.com/mime-db-cdn@\u003ctag\u003e/file-types/type.\u003cextension\u003e\n```\n\n`Content-Type` header received for a `GET` request to the above URLs might contain the desired MIME-type, as provided by the CDN provider.\n\n👉 The above links also return the actual MIME-types as text in the response body. For extensions shared by multiple MIME-types, one MIME-type is listed per line. Note that these MIME-types are not sorted in any particular order. If a sorted list is required, [download the JSON](#file-extension-to-mime-types).\n\n### Versioning\nThe source `mime-db` release, from which our [database](https://github.com/SomajitDey/mime-db-cdn/tree/database) is built, is always recorded as a [semver pre-release](https://semver.org/).\n\nFormat: `\u003cour version\u003e-\u003csource mime-db version\u003e`\n\nFor example, our version [4.0.0-1.54.0](https://github.com/SomajitDey/mime-db-cdn/releases/tag/4.0.0-1.54.0) is equivalent to the `mime-db` release [v1.54.0](https://github.com/jshttp/mime-db/releases/tag/v1.54.0).\n\n### Examples\nJust click on any of the links in this section.\n\n👉 Data for `image/jpeg` from [mime-db release v1.54.0](https://github.com/jshttp/mime-db/releases/tag/v1.54.0) =\u003e\n\nhttps://cdn.jsdelivr.net/gh/somajitdey/mime-db-cdn@4.0.0-1.54.0/mime-types/image/jpeg/data.json\n\n👉 MIME-type(s) for file-extension `exe`=\u003e\n\nhttps://unpkg.com/mime-db-cdn@4.0.0-1.54.0/extensions/exe/data.json\n\n👉 Proper `Content-Type` for file-extensions `json` and `png` =\u003e\n\nhttps://unpkg.com/mime-db-cdn@4.0.0-1.54.0/file-types/type.json\n\nhttps://unpkg.com/mime-db-cdn@4.0.0-1.54.0/file-types/type.png\n\n## JavaScript SDK\n\nOur [JS-SDK](./index.js) is designed to be memory-efficient regardless of how big the original [MIME-type database](https://github.com/jshttp/mime-db/blob/master/db.json) ever becomes. This is acheived through [dynamic import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import)s, viz. importing data as and when needed.\n\nFor browsers, this means more requests to the [CDNs](#usage) in return for low memory footprint. Thanks to caching by the browsers, however, the increased CDN requests might ultimately be a non-issue.\n\nFor server-side runtimes like Node, dynamically importing tiny JSONs avoids complexities of [reading and parsing a huge JSON database using streams](https://www.npmjs.com/package/stream-json).\n\n### Install and Import\nFor browsers:\n```html\n\u003cscript type=\"module\"\u003e\n    import { mimeToExtensions, extensionToMimes } from 'https://cdn.jsdelivr.net/npm/mime-db-cdn@4.0.0-1.54.0/index.min.js';\n\n    // Your code here ...\n\u003c/script\u003e\n```\n\nFor Node.js:\n\nInstall as\n```bash\nnpm install mime-db-cdn\n```\n\nImport as\n```javascript\nimport { mimeToExtensions, extensionToMimes } from 'mime-db-cdn';\n```\n\n### API\n#### mimeToExtensions(`mimeType`)\nReturns a promise that fulfills with an array of file-extensions.\n\n`mimeType`\n\nString representing a MIME-type with [structure](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types#structure_of_a_mime_type):\n```\ntype/subtype\n\ntype/subtype;parameter=value\n```\n\nThe returned promise is rejected with `Not Found` error if the provided `mimeType` is unavailable in [mime-db](https://github.com/jshttp/mime-db).\n\nExamples:\n```javascript\nconsole.log(await mimeToExtensions('application/mp4'));\n// Prints [ 'mp4', 'mpg4', 'mp4s', 'm4p' ]\n\nconsole.log(await mimeToExtensions('application/javascript; charset=utf-8'));\n// Prints [ 'js' ]\n```\n\n#### extensionToMimes(`extension`)\nReturns a promise that fulfills with an array of MIME-types.\n\n`extension`\n\nString representing either of\n- path, e.g. `dir/subdir/file.ext`\n- file-extension with or without the leading dot, e.g. `mp4`, `.mp4`\n- file-name, e.g. `file.mp4`, `file.version.1.2.0.mp4`\n\nThe returned promise is rejected with `Not Found` error if the provided `mimeType` is unavailable in [mime-db](https://github.com/jshttp/mime-db).\n\nExamples:\n```javascript\nconsole.log(await extensionToMimes('dir/subdir/path.version.js'));\n\nconsole.log(await extensionToMimes('js'));\n\nconsole.log(await extensionToMimes('.js'));\n\n// Prints [ 'application/javascript', 'text/javascript' ]\n```\n\n### Alternatives\n- [mime-db-lite](https://github.com/SomajitDey/mime-db-lite)\n\n## Reliability of this database\nThe upstream [mime-db](https://github.com/jshttp/mime-db) is [checked daily for updates](https://github.com/SomajitDey/mime-db-cdn/actions). If a new [release](https://github.com/jshttp/mime-db/releases) is available upstream, [this database](https://github.com/SomajitDey/mime-db-cdn/tree/database) is [built](scripts/build-db.js) afresh from that release. A new [git-tag](https://github.com/SomajitDey/mime-db-cdn/tags), and an [npm package](https://www.npmjs.com/package/mime-db-cdn) are then released, with appropriate [versioning](#versioning).\n\n# Contribute\nTo register new media types in the database, [contribute directly to mime-db](https://github.com/jshttp/mime-db#contributing).\n\nIf you like this project, you can show your appreciation by\n- [giving it a star](https://github.com/SomajitDey/mime-db-cdn/stargazers) ⭐\n-  sponsoring me through 👇\n\n[![Sponsor](https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png)](https://buymeacoffee.com/SomajitDey)\n\nThank you 💚.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomajitdey%2Fmime-db-cdn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsomajitdey%2Fmime-db-cdn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomajitdey%2Fmime-db-cdn/lists"}