BYTETOOLS

MIME Type Mistakes and Best Practices to Avoid

The most common MIME type mistakes are serving files as application/octet-stream when they have a real type, omitting charset=utf-8 on text responses, and guessing a content type instead of confirming it. Each one produces confusing symptoms — files that download instead of opening, garbled accented characters, or APIs that reject valid data. Confirming the exact value in a lookup before you ship it prevents nearly all of them.

This guide collects the pitfalls that trip up developers when configuring servers and setting headers, plus the practices that keep content types correct across browsers and clients.

Common mistakes and how to fix them

MistakeSymptomFix
Serving everything as application/octet-streamImages and PDFs download instead of previewingSet the real type, e.g. image/png, application/pdf
Missing charset on textAccented or non-ASCII characters look garbledUse text/html; charset=utf-8
Wrong JSON headerClients fail to parse or reject the bodyUse application/json, not text/plain
Old font MIME typesFonts fail to load in strict browsersServe font/woff2 for WOFF2
Trusting the file extension for uploadsMalicious files slip through validationCheck the real type server-side, not just the name

Best practices for setting content types

  • Confirm, don't guess. Before pasting a Content-Type into config, verify the exact spelling and subtype. A typo like applicaton/json silently breaks parsing.
  • Always add a charset to text. HTML, CSS, JavaScript and plain text should carry ; charset=utf-8 so browsers decode multi-byte characters correctly.
  • Use the modern subtype. Prefer application/javascript over the deprecated text/javascript, and font/woff2 over old application/font-woff variants.
  • Match extension and type deliberately. Remember .jpg and .jpeg both map to image/jpeg; make sure your server's map covers both so neither slips through as octet-stream.
  • Set download behaviour with Content-Disposition, not a fake type. To force a download, keep the correct content type and add Content-Disposition: attachment instead of mislabelling the file.

Troubleshooting a wrong content type

When a file behaves oddly, work backwards. Open your browser's network panel and read the actual Content-Type the server sent. If it says application/octet-stream or text/plain where you expected something specific, that mismatch is almost always the cause. Take the extension, look up the correct type, and update your server's MIME map or the header you set in code. Re-request with a hard refresh to bypass a cached response.

A quick way to sanity-check the correct value is to search the extension and read the canonical type and description side by side — it removes the guesswork that causes most of these bugs.

Try the MIME Type Lookup — free and 100% in your browser.

FAQ

Why does adding charset to a MIME type matter?

Without charset=utf-8, some browsers fall back to a legacy encoding and render accented or non-Latin characters incorrectly. Adding the charset parameter to text content types guarantees consistent decoding everywhere.

Is text/javascript wrong for serving scripts?

It still works in browsers, but text/javascript is technically obsolete. The recommended type is application/javascript (or text/javascript only where legacy tooling requires it). Confirm the value you intend to serve before locking it into config.

Should I trust the MIME type a browser reports on upload?

No. The browser derives it from the file name and can be spoofed, so treat client-supplied content types as hints only. Validate the real type on the server before storing or serving user uploads.

Why do two files with the same extension get different behaviour?

Usually because one server has the extension mapped correctly and another falls back to octet-stream. Compare the response headers from each and align the MIME maps so both serve the canonical type.

Related free tools

Built by ByteVancer

ByteTools is a free product of ByteVancer, a software and web development studio building web apps, SaaS and custom software. If server configuration and content delivery are eating your team's time, explore how ByteVancer can help you ship faster.