MIME Type Detector
Detect MIME types from file extensions, magic numbers, or data URIs
Examples
Detect from a file extension
Mode: Extension · Input: pngimage/png
PNG image format with transparency
Extension: .png
Category: image
Browser Support: Full
Security: Safe
Magic Number: 89 50 4E 47 0D 0A 1A 0AExtension 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
Mode: Magic Number · Input: FF D8 FFimage/jpeg
JPEG image format
Extension: .jpg
Category: image
Browser Support: Full
Security: Safe
Magic Number: FF D8 FFThe 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
Mode: Data URI · Input: data:image/png;base64,iVBORw0KGgo…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
Mode: Content · Input: <!DOCTYPE html><html><head><title>x</title></head></html>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 this tool
Pick the input mode
Switch between Extension, Magic Number, Data URI and Content tabs depending on what you have to hand.
Type or paste the input
Use the sample buttons for a quick test (PNG, JPEG, PDF, ZIP), or paste your own value.
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
| Mode | What you enter |
|---|---|
| Extension | A file extension like png or .png |
| Magic number | The first hex bytes of the file, e.g. 89 50 4E 47 |
| Data URI | A full data URI like data:image/png;base64,… |
| Content | The 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
How does it decide a file's type?
It tries three sources in priority order: the binary signature (magic bytes) at the start of the file, the file extension you pass along with it, and a quick decode of a data URI prefix. Magic-byte detection is the most reliable because it works even when the extension is wrong or missing.
What is a magic number?
A short byte sequence at the start of a file that identifies its format independently of the extension — PNG files always start with the bytes 89 50 4E 47, JPEG files with FF D8 FF, and PDF files with the ASCII string %PDF-. Detectors use these constants to verify the actual format.
Can a wrong extension fool the detector?
No. When magic-byte detection is enabled, the file's actual contents decide the answer. An MP4 renamed to .jpg still resolves to a video MIME type — useful for catching mismatched uploads.
Is the file uploaded?
No. Detection runs entirely in your browser on the bytes you provide; nothing leaves your device.
Related guides
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
AI Function Calling Schema Generator
Generate function calling JSON schemas from TypeScript interfaces
Algorithm Arena & Data Structure Visualizer
Interactive arena for algorithms and data structures: eight sorting algorithms racing on one seeded input, six pathfinding algorithms walking generated mazes, and BST, AVL, Red-Black, B-tree, heap and trie operations replayed step by step with rotations highlighted. Every run shows the Big-O table and the phase-highlighted reference implementation in four languages, and compared values can be played as pitch (sonification) through the shared audio engine. Everything runs client-side; inputs never leave the browser.
Ansible Playbook Generator
Build an Ansible playbook — hosts, vars, and tasks with modules — as YAML