עברית 📰 Blog
← Back to Blog
AI Tools

Magika: The File-Detection Model Google Runs on Billions of Files a Week

Claudia
Masterphub AI
August 27, 2026

Share this article

Magika: The File-Detection Model Google Runs on Billions of Files a Week

Every file that hits Gmail, Google Drive, or Safe Browsing gets checked: what kind of file is this, really? Not by its extension, which anyone can fake, but by its actual content. Google built a small AI model to do that check in milliseconds, then open-sourced it. It's called Magika.

What it actually does

File type detection sounds simple until you've dealt with it. Extensions lie. Magic bytes miss edge cases. Traditional tools guess wrong constantly on messy real-world files — the kind an email attachment scanner or a cloud storage system has to process by the billion.

Magika replaces that guesswork with a deep learning model trained on about 100 million samples across more than 200 content types. It reads the actual bytes and predicts the type, no extension required. Google reports about 99% average accuracy on its test sets.

Small and fast

The model is a few megabytes. Inference takes about 5 milliseconds per file, and that time stays close to constant regardless of file size — it doesn't get slower on a bigger file the way some scanners do.

That's the part that makes it usable at Google's scale: hundreds of billions of file checks a week, according to the project. Whatever detects the type has to be fast enough not to become the bottleneck.

How you'd actually use it

Magika ships three ways: a command-line tool written in Rust, a Python API, and JavaScript/TypeScript bindings. There's also a web demo if you just want to try it on a file without installing anything.

Google uses it internally across Gmail, Drive, and Safe Browsing, and it's integrated into VirusTotal and abuse.ch for threat detection — both used by security teams to check whether a file is what it claims to be before opening it.

Why it's on GitHub at all

Magika has 17.3k stars and runs under an Apache 2.0 license, so anyone can use it, including commercially. Google didn't have to open-source an internal security tool. They did anyway, which is worth noting on its own: a model built for a specific internal problem at massive scale, handed to anyone who has the same problem at any scale.

If you build anything that has to trust unknown files, an upload handler, a content pipeline, a scanner, this is the kind of tool worth knowing exists before you write your own file-sniffing logic from scratch.

Share this article