Magika is an AI-powered file type detection tool that uses deep learning to identify file content types with high accuracy.
The tool addresses the challenge of reliably determining what type of file you are dealing with, which matters for security scanning, content policy enforcement, and file routing. Magika trains a custom deep learning model on a large dataset of files across many content types and runs inference on just a limited portion of each file's content, achieving results in milliseconds even on a single CPU. The model itself is compact, weighing only a few megabytes, and the tool exposes detection through multiple interfaces: a command-line tool written in Rust, a Python API, and bindings for JavaScript/TypeScript and Go. Users can control tolerance for errors through different prediction modes and per-content-type confidence thresholds that determine whether to return a specific classification or a generic fallback label.
Magika suits projects that need fast, accurate file identification at scale, particularly those handling security-sensitive operations like email scanning or malware detection. The tool's near-constant inference time regardless of file size and ability to process thousands of files simultaneously make it practical for high-volume scenarios. The command-line interface and Python API both support recursive directory scanning. If you need file type detection beyond what traditional MIME type checking provides, especially for distinguishing between similar textual formats, this tool's deep learning approach offers a significant accuracy advantage over existing methods.
The project receives issue reports primarily from outside users rather than the core team, indicating a substantial base of real-world adopters. Maintainers typically respond to new issues and pull requests within a few days. Work in the issue tracker centers on Python-related matters, missing content type support, and content type knowledge base imports.