1001Ferramentas
📎Dev

MIME Type por Extensão

Retorna o MIME type oficial para uma extensão de arquivo.

MIME

Picking the right Content-Type for a file extension

The browser downloaded your file instead of opening it, or the stylesheet arrived as text/plain and the page rendered with no styling at all. The Content-Type header the server sent is almost always the culprit. Type an extension, with or without the leading dot, and you get the MIME type to use. The table covers 36 common extensions across web, images, audio, video, fonts and archives.

When an extension is not in the table, the answer is application/octet-stream, which is precisely the value that makes a browser offer a download rather than render the file. Two conventions are worth calling out. The table returns application/javascript for .js, the older form every browser accepts, even though IANA now prefers text/javascript. And it returns image/x-icon for .ico, the de facto value, not the registered image/vnd.microsoft.icon.

The MIME type alone is not enough for text: for HTML, CSS, JS and JSON add charset=utf-8 to the header, or the browser guesses the encoding and your accented characters turn into garbage. If you accept uploads, never trust the extension, since the uploader picks it. Check the leading bytes of the file and serve with X-Content-Type-Options: nosniff. The lookup is a fixed table inside the page and no file is uploaded.

Frequently asked questions

Should I use application/javascript or text/javascript for .js files?
Both work in every current browser. IANA deprecated application/javascript in favor of text/javascript, but no client will complain about the older value.
Why does my file download instead of opening in the browser?
Usually because the server is sending application/octet-stream, the generic fallback. Configure the correct MIME type for that extension in your server or CDN.
Does this tool detect the type from the file contents?
No. It only maps an extension to a MIME type. Content-based detection means reading the magic bytes at the start of the file, which is a different kind of analysis.

Related Tools