All 45 Dependencies

Every package magika depends on, ranked by repo health score.

Magika is a novel file type detection tool developed by Google that replaces heuristic-based approaches with deep learning. Rather than relying on magic bytes or file extensions, Magika analyzes the actual byte content of a file through a custom-trained neural network, achieving approximately 99% average precision and recall across more than 200 content types spanning both binary and text formats.

The tool is used at Google's production scale to route files through security and content policy scanners across Gmail, Drive, and Safe Browsing—processing hundreds of billions of samples weekly. It has also been integrated with VirusTotal and abuse.ch, demonstrating its value in security-critical pipelines where misclassification has real consequences.

Magika is designed for speed and portability: after a one-time model load, inference takes approximately 5 milliseconds per file even on a single CPU, and the model itself weighs only a few megabytes. It reads only a limited subset of each file's bytes, meaning inference time remains near-constant regardless of file size. Files can be processed individually or in bulk batches of thousands at a time.

The project ships as a Rust-based CLI tool, a Python library with ONNX runtime inference, and experimental JavaScript/TypeScript bindings that run entirely in the browser via WebAssembly. GoLang bindings are in progress. A configurable prediction mode system (high-confidence, medium-confidence, best-guess) lets users tune the trade-off between precision and generality.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search