Skip to content
gohacks.dev
Security

File Type Detector

Find out what a file really is from its first bytes (PNG, JPEG, PDF, ZIP, ELF, SQLite and dozens more) and whether that matches its extension.

Free · No sign-up · Your inputs stay in your browser

Input

Detect a file's real type from its magic bytes

Output

Choose a file

Only the first 512 bytes are read. The extension and the browser's reported type both come from the file name, which anyone can change; the signature at the start of the file is what the program opening it actually sees. Validate uploads the same way on the server: PHP's finfo_file() and the file command read these signatures.

Runs in this browser. Nothing you paste is sent to a server.

Extensions lie

A file's name and the browser-reported MIME type both come from the name, which anyone can change. The bytes at the start of the file are what the program opening it reads. Upload validation that trusts the extension accepts a PHP script named avatar.jpg. Check content on the server with PHP's finfo_file(), Python's python-magic or the file command, which use the same kind of signature database.

Containers

DOCX, XLSX, JAR, APK and EPUB are ZIP files with a particular layout, so their signature is ZIP's; telling them apart needs a look inside.

Share

Frequently asked questions

How do I check a file's type on Linux?
file name.ext prints the detected type, and file --mime-type gives the MIME type, from the libmagic signature database.
Is the whole file read?
No, only the first 512 bytes, in the browser. The file is not uploaded.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools