Magika detects file content types using a compact deep learning model, with millisecond inference on a single CPU. It ships as a Rust CLI, Python API, and other language bindings.
Overview
Magika identifies what kind of file you are dealing with by analyzing a small slice of file content with a lightweight neural model. It targets both binary and text formats and is designed for speed after an initial model load, with roughly five milliseconds per file on one CPU.
The tool supports batch and recursive directory scans and exposes several prediction modes that trade off confidence against guess quality. When confidence is low, it can return generic labels instead of a specific type. Bindings include a Rust command-line client, a Python module installable via pip, JavaScript and TypeScript (including a browser demo), Rust libraries, and work-in-progress Go support.
Google uses Magika in production to route Gmail, Drive, and Safe Browsing uploads toward appropriate security and policy scanners. Integrations also appear in VirusTotal and abuse.ch workflows. The project supports major desktop operating systems and optional GPU acceleration in newer release candidates.
Key features
- AI-based content type detection
- Rust CLI and Python API
- Recursive directory scanning
- Per-type confidence thresholds
- Adjustable prediction modes
- Millisecond CPU inference
- Browser-local web demo
- Multi-language bindings
Use cases
- Classifying uploads before security scanning
- Sorting unknown files in pipelines
- Batch MIME-style identification in scripts
- Trying detection in the browser demo