DevTools Logo

MIME Type Detector

MIME Type Detector

Detect MIME types from file extensions, magic numbers, or data URIs

Detection Input

    Examples

    Detect from a file extension

    Input
    Mode: Extension · Input: png
    Output
    image/png
    PNG image format with transparency
    Extension: .png
    Category: image
    Browser Support: Full
    Security: Safe
    Magic Number: 89 50 4E 47 0D 0A 1A 0A

    Extension lookup hits a direct map (.png → image/png) and returns the full MimeInfo record, including the magic-number header used to confirm the file on disk.

    Detect from a magic-number sequence

    Input
    Mode: Magic Number · Input: FF D8 FF
    Output
    image/jpeg
    JPEG image format
    Extension: .jpg
    Category: image
    Browser Support: Full
    Security: Safe
    Magic Number: FF D8 FF

    The detector strips spaces, uppercases the input, and matches the longest prefix against the magic-number table — FF D8 FF is the standard JPEG SOI marker.

    Detect from a data URI

    Input
    Mode: Data URI · Input: data:image/png;base64,iVBORw0KGgo…
    Output
    image/png
    PNG image format with transparency
    …

    The data: prefix is recognised by the regex /^data:([^;,]+)(;base64)?,/i and the captured MIME type is looked up in the database.

    Detect HTML content by signature

    Input
    Mode: Content · Input: <!DOCTYPE html><html><head><title>x</title></head></html>
    Output
    text/html
    HTML document
    …
    UTF-8 compatible text format
    Compressible (use gzip/brotli)

    Content mode matches HTML, JSON and XML by their first-byte and structure patterns. text/html is flagged compressible and UTF-8, which is how Nginx and CDNs decide to gzip responses.

    About this tool

    A MIME type is the standard label browsers, servers and APIs use to identify a file's content — image/png, application/pdf, audio/mpeg, and so on. Choosing the right one is what lets a browser render an inline image instead of triggering a download, and it's what makes a Content-Type header on an upload endpoint actually mean something.

    This detector identifies MIME types from four different inputs. Paste a file extension (.png, png), a magic-number sequence in hex (89 50 4E 47), a full data URI (data:image/png;base64,iVBORw0…), or the first bytes of a text-based file (HTML, JSON, XML) and the tool returns the canonical MIME type, default extension, description, browser support level, security rating, and — for known formats — the magic number.

    Detection runs against a built-in database of ~40 common types across image, video, audio, text, application, font and message categories. Everything is local; nothing is uploaded.

    How to use

    1. Pick the input mode

      Switch between Extension, Magic Number, Data URI and Content tabs depending on what you have to hand.

    2. Type or paste the input

      Use the sample buttons for a quick test (PNG, JPEG, PDF, ZIP), or paste your own value.

    3. Read the result

      The tool returns the canonical MIME type, default extension, category, common extensions, magic number, browser support, security flag and any text-format flags (UTF-8, compressible).

    Use cases

    Mapping a Content-Type header on an upload

    Drop a sample file's magic-number header into the Magic tab to confirm the canonical MIME type before setting Content-Type on a multipart upload.

    Sanity-checking a Content-Type sniffing rule

    When writing code that sniffs MIME from raw bytes, use the tool as a quick oracle — paste the first bytes and confirm the answer your code would compute.

    Auditing what browser features a type has

    The result panel shows browser-support (Full / Partial / None) and security rating (Safe / Caution / Dangerous) for every detected type — handy when reviewing a CSP or a download whitelist.

    Validating a custom data URI

    Paste an inline data URI from a stylesheet or an email template and confirm the MIME and encoding match the use case.

    Detection modes

    ModeWhat you enter
    ExtensionA file extension like png or .png
    Magic numberThe first hex bytes of the file, e.g. 89 50 4E 47
    Data URIA full data URI like data:image/png;base64,…
    ContentThe first bytes of a text file (HTML, JSON, XML)

    For unknown or custom MIME types the tool still parses a data URI and returns the type string with a 'caution' security flag.

    Common mistakes

    Mistake:Trusting the file extension alone.

    Fix:Extensions are advisory — a renamed .exe is still a Windows executable. Use magic numbers or content sniffing for any security decision (uploads, attachment filters).

    Mistake:Treating text/html and application/xhtml+xml as interchangeable.

    Fix:The detector returns text/html for content starting with <html or <!doctype html. For XHTML with an XML declaration, use application/xhtml+xml and Content-Type: application/xml.

    Mistake:Assuming every unknown type is dangerous.

    Fix:Custom or rare MIME types are flagged caution by default, but they aren't inherently unsafe. The flag just means 'no built-in metadata — verify by other means'.

    Mistake:Forgetting to also check the magic number for files served as text/plain.

    Fix:Servers often mislabel binary files as text/plain to avoid X-Content-Type-Options warnings. Always sniff with a magic-number check before serving.

    Frequently asked questions

    References & standards