{
 "kind": "tool",
 "slug": "mime-types",
 "path": "tools/mime-types/",
 "name": "mime-types",
 "maker": null,
 "density": "full",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Utilities",
   "tools/utilities/"
  ]
 ],
 "lead": "The right file type for any file name.",
 "chips": [
  {
   "label": "Utilities",
   "path": "tools/utilities/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install mime-types"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/jshttp/mime-types"
  },
  {
   "label": "Website",
   "href": "https://github.com/jshttp/mime-types#readme"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": "Permission is hereby granted, free of charge, to any person obtaining a copy of this software",
   "note": "Paid and closed-source products may use it; no fee and no on-screen credit needed.",
   "src": "https://github.com/jshttp/mime-types/blob/master/LICENSE"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Jun 2, 2026",
   "note": "Latest GitHub release Nov 20, 2025. ",
   "src": "https://github.com/jshttp/mime-types"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "22 projects",
   "status": "info",
   "sub": "#69 of 408 in its category",
   "note": "Dependency in 22 public GitHub projects set up for AI coding agents that we scanned (0.4%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily; card checked Nov 10, 2026.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What mime-types does",
   "parts": [
    {
     "t": "prose",
     "text": "mime-types is a small free JavaScript package for Node.js servers. Give it a file name like report.pdf and it returns the type label browsers expect, such as application/pdf, or the other way round. Your server then sends files that open in the browser instead of downloading as unknown data."
    },
    {
     "t": "h3",
     "text": "What people build with it"
    },
    {
     "t": "uses",
     "items": [
      {
       "title": "Serve files with the right type",
       "text": "Your app sends uploaded files or generated reports from its own route; each one gets the matching Content-Type header, so a PDF opens in the browser tab.",
       "idea": false
      },
      {
       "title": "Accept only pictures in an upload form",
       "text": "Before saving an avatar, check that the file name ends in a picture type you allow and reject the others with a clear message.",
       "idea": true
      },
      {
       "title": "Name files you download",
       "text": "Your app fetches a file from another service and only knows its type; mime-types gives the extension to save it under, such as .png or .pdf.",
       "idea": false
      },
      {
       "title": "A safe default for unknown files",
       "text": "Files with no or a strange extension get the generic binary type, so browsers download them instead of guessing.",
       "idea": false
      },
      {
       "title": "Mark text files as UTF-8",
       "text": "Markdown, CSV and other text files get charset=utf-8 added to their type, so accents and emoji show correctly.",
       "idea": false
      },
      {
       "title": "Set the type on cloud storage uploads",
       "text": "When your app puts files into cloud storage, pass the looked-up type along, so the public link opens a picture instead of downloading it.",
       "idea": true
      }
     ]
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "mime-types popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "62",
       "of": "/ 100",
       "l": "Gid Score, #907 overall"
      },
      {
       "n": "414M",
       "l": "downloads a week, npm"
      },
      {
       "n": "1,480",
       "l": "GitHub stars"
      },
      {
       "n": "22",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How mime-types is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "mime-types is a dependency in 22 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (0.5% of the 4,867 JavaScript/TypeScript ones), #69 of 408 in utilities.",
      "Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 73; those are left out of every share on this page.",
      "Projects that use it most often also use esbuild (50.0%), date-fns (45.5%), cross-env (36.4%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "13 projects, 0.4%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "11 projects, 0.5%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "6 projects, 0.2%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "5 projects, 1.1%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 50.0% of its projects",
       "v": "esbuild",
       "path": "tools/esbuild/"
      },
      {
       "l": "In 45.5% of its projects",
       "v": "date-fns",
       "path": "tools/date-fns/"
      },
      {
       "l": "In 36.4% of its projects",
       "v": "cross-env",
       "path": "tools/cross-env/"
      },
      {
       "l": "In 36.4% of its projects",
       "v": "Framer Motion",
       "path": "tools/framer-motion/"
      },
      {
       "l": "In 36.4% of its projects",
       "v": "lint-staged",
       "path": "tools/lint-staged/"
      },
      {
       "l": "In 90.9% of its projects",
       "v": "TypeScript",
       "path": "tools/typescript/"
      },
      {
       "l": "In 54.5% of its projects",
       "v": "Prettier",
       "path": "tools/prettier/"
      },
      {
       "l": "In 59.1% of its projects",
       "v": "Zod",
       "path": "tools/zod/"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "usage",
   "h2": "More about mime-types",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "Open Collective: https://opencollective.com/express"
       ]
      },
      {
       "title": "More in Utilities",
       "path": "tools/utilities/",
       "items": [
        {
         "text": "clsx",
         "path": "tools/clsx/"
        },
        {
         "text": "date-fns",
         "path": "tools/date-fns/"
        },
        {
         "text": "PyYAML",
         "path": "tools/pyyaml/"
        },
        {
         "text": "uuid",
         "path": "tools/uuid/"
        },
        {
         "text": "yaml",
         "path": "tools/yaml/"
        },
        {
         "text": "js-yaml",
         "path": "tools/js-yaml/"
        },
        {
         "text": "glob",
         "path": "tools/glob/"
        },
        {
         "text": "Lodash",
         "path": "tools/lodash/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "mime-types",
       "me": true,
       "facts": [
        "MIT",
        "Gid 62",
        "414M/wk"
       ]
      },
      {
       "name": "file-type",
       "why": "Pick file-type when you must know what a file really is from its bytes, for example to block a renamed program in uploads.",
       "path": "tools/file-type/",
       "facts": []
      },
      {
       "name": "mime",
       "why": "Pick mime when your project uses ES modules and you want its getType and getExtension calls or the smaller mime/lite build.",
       "path": "tools/mime/",
       "facts": []
      }
     ],
     "more": "Compare mime-types with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "prompt",
     "text": "Use the npm package mime-types (pin mime-types@3.0.2, Node.js 18+) to set the Content-Type header for files my server sends, with mime.contentType(path.extname(file)) and application/octet-stream when it returns false."
    },
    {
     "t": "steps",
     "items": [
      {
       "text": "Add the package to your Node.js project (Node.js 18 or newer for version 3).",
       "code": "npm install mime-types",
       "src": "https://github.com/jshttp/mime-types/blob/master/README.md"
      },
      {
       "text": "Load it and look up types by file name or extension.",
       "code": "var mime = require('mime-types')\nmime.lookup('file.html') // 'text/html'\nmime.contentType('file.json') // 'application/json; charset=utf-8'\n",
       "src": "https://github.com/jshttp/mime-types/blob/master/README.md"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Mistakes to avoid"
    },
    {
     "t": "mistakes",
     "items": [
      {
       "dont": "mime.contentType('uploads/report.pdf') or any value that contains a slash",
       "fix": "mime.contentType(path.extname(file)) or mime.lookup(file)",
       "why": "contentType() treats anything with a slash as a ready type and returns it unchanged; in our run 'folder/.htaccess' came back as the \"type\"."
      },
      {
       "dont": "res.setHeader('Content-Type', mime.lookup(name))",
       "fix": "res.setHeader('Content-Type', mime.contentType(path.extname(name)) || 'application/octet-stream')",
       "why": "Unknown names give false, which is not a valid header value, and lookup() does not add charset=utf-8 for text."
      },
      {
       "dont": "mime.getType(name) or mime.getExtension(type)",
       "fix": "mime.lookup(name) and mime.extension(type)",
       "why": "getType and getExtension belong to the separate mime package; mime-types keeps the mime 1.x names."
      },
      {
       "dont": "Naming an MP3 download with mime.extension('audio/mpeg')",
       "fix": "Keep a small map for the types you care about (audio/mpeg -> mp3) and fall back to mime.extension()",
       "why": "extension() returns the first extension in mime-db's list; in our run audio/mpeg gave \"mpga\"."
      },
      {
       "dont": "Expecting the same answers after upgrading from 2.x (for example text/xml for .xml)",
       "fix": "Re-check the types your app depends on after an upgrade to 3.x",
       "why": "Version 3.0.0 changed several answers to settle conflicts between sources."
      }
     ]
    }
   ]
  },
  {
   "id": "faq",
   "nav": "Questions",
   "h2": "Questions",
   "parts": [
    {
     "t": "faq",
     "items": [
      {
       "q": "Does it check what is inside the file?",
       "a": "No. It looks only at the extension in the name; for real content checks use a package that reads the file's first bytes, such as file-type.",
       "evidence": {
        "url": "https://github.com/jshttp/mime-types/blob/master/index.js",
        "quote": "get the extension (\"ext\" or \".ext\" or full path)"
       }
      },
      {
       "q": "What does it return for a file it does not know?",
       "a": "false. Add your own fallback, usually application/octet-stream.",
       "evidence": {
        "url": "https://github.com/jshttp/mime-types/blob/master/README.md",
        "quote": "var type = mime.lookup('unrecognized') || 'application/octet-stream'"
       }
      },
      {
       "q": "Where do the types come from?",
       "a": "From mime-db, a list built from the official IANA register and the Apache and nginx web server lists.",
       "evidence": {
        "url": "https://github.com/jshttp/mime-db/blob/master/README.md",
        "quote": "It aggregates data from the following sources"
       }
      },
      {
       "q": "Is it the same as the mime package?",
       "a": "No. Its calls match the old mime 1.x style (lookup, extension), not mime's newer getType and getExtension.",
       "evidence": {
        "url": "https://github.com/jshttp/mime-types/blob/master/README.md",
        "quote": "Otherwise, the API is compatible with mime 1.x."
       }
      },
      {
       "q": "Can I use it in a paid app?",
       "a": "Yes. It is MIT licensed; keep the license notice when you ship its files.",
       "evidence": {
        "url": "https://github.com/jshttp/mime-types/blob/master/LICENSE",
        "quote": "Permission is hereby granted, free of charge, to any person obtaining a copy of this software"
       }
      }
     ]
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm mime-types"
  ],
  [
   "Category",
   "Utilities"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Gid Score",
   "61.6"
  ],
  [
   "Rank in category",
   "#69 of 408"
  ],
  [
   "GitHub",
   "jshttp/mime-types"
  ],
  [
   "Last change",
   "Jun 2, 2026"
  ]
 ],
 "good": [
  "It reads only the file name, never the file itself; a renamed file passes as whatever its name says.",
  "Unknown names give false, not a default type, so your code has to supply the fallback.",
  "Version 3 needs Node.js 18 or newer and changed some answers, for example .xml and .rtf."
 ],
 "checked_line": "Read by AgentGid from 8 official pages, card checked Nov 10, 2026; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/jshttp.png"
}