magika
A tool to determine the content type of a file with deep learning
Description
# Magika Python Package [](https://pypi.python.org/pypi/magika) [](https://npmjs.com/package/magika) [](https://pypi.python.org/pypi/magika) [](https://pypi.python.org/pypi/magika) [](https://www.bestpractices.dev/en/projects/8706)  [](https://github.com/google/magika/actions) [](https://pepy.tech/projects/magika) [](https://pepy.tech/projects/magika) <!-- [](https://securityscorecards.dev/viewer/?uri=github.com/google/magika) --> Magika is a novel AI-powered file type detection tool that relies on the recent advance of deep learning to provide accurate detection. Under the hood, Magika employs a custom, highly optimized model that only weighs about a few MBs, and enables precise file identification within milliseconds, even when running on a single CPU. Magika has been trained and evaluated on a dataset of ~100M samples across 200+ content types (covering both binary and textual file formats), and it achieves an average ~99% accuracy on our test set. Use Magika as a command line client or in your Python code! You can find more information on which content types are supported, extended documentation, and bindings for other languages on Magika's website at [https://securityresearch.google/magika/](https://securityresearch.google/magika/). ## Installing Magika Magika is available as `magika` on [PyPI](https://pypi.org/project/magika): To install the most recent stable version: ```shell pip install magika ``` If you intend to use Magika only as a command line, you may want to use `pipx install magika` instead. If you want to test out the latest release candidate, you can install it with `pip install --pre magika`. ## Using Magika as a command-line tool > Beginning with version `0.6.0`, the magika Python package includes a pre-compiled Rust-based command-line tool, replacing the previous Python version. This binary is distributed as platform-specific wheels for most common architectures. For unsupported platforms, a pure-Python wheel is also available, providing the legacy Python client as a fallback. ```shell $ cd tests_data/basic && magika -r * asm/code.asm: Assembly (code) batch/simple.bat: DOS batch file (code) c/code.c: C source (code) css/code.css: CSS source (code) csv/magika_test.csv: CSV document (code) dockerfile/Dockerfile: Dockerfile (code) docx/doc.docx: Microsoft Word 2007+ document (document) epub/doc.epub: EPUB document (document) epub/magika_test.epub: EPUB document (document) flac/test.flac: FLAC audio bitstream data (audio) handlebars/example.handlebars: Handlebars source (code) html/doc.html: HTML document (code) ini/doc.ini: INI configuration file (text) javascript/code.js: JavaScript source (code) jinja/example.j2: Jinja template (code) jpeg/magika_test.jpg: JPEG image data (image) json/doc.json: JSON document (code) latex/sample.tex: LaTeX document (text) makefile/simple.Makefile: Makefile source (code) markdown/README.md: Markdown document (text) [...] ``` ```shell $ magika ./tests_data/basic/python/code.py --json [ { "path": "./tests_data/basic/python/code.py", "result": { "status": "ok", "value": { "dl": { "description": "Python source", "extensions": [ "py", "pyi" ], "group": "code", "is_text": true, "label": "python", "mime_type": "text/x-python" }, "output": { "description": "Python source", "extensions": [ "py", "pyi" ], "group": "code", "is_text": true, "label": "python", "mime_type": "text/x-python" }, "score": 0.753000020980835 } } } ] ``` ```shell $ cat doc.ini | magika - -: INI configuration file (text) ``` ```help $ magika --help Determines the content type of files with deep-learning Usage: magika [OPTIONS] [PATH]... Arguments: [PATH]... List of paths to the files to analyze. Use a dash (-) to read from standard input (can only be used once). Options: -r, --recursive Identifies files within directories instead of identifying the directory itself --no-dereference Identifies symbolic links as is instead of identifying their content by following them --colors
Release History
| Version | Changes | Urgency | Date |
|---|---|---|---|
| 1.0.2 | Imported from PyPI (1.0.2) | Low | 4/21/2026 |
| cli-latest | This moving release simply replicates the assets and commit hash of the latest CLI release. The latest CLI release is [cli/v1.0.2](https://github.com/google/magika/releases/tag/cli/v1.0.2). | High | 4/16/2026 |
| python-v1.0.2 | Changelog: - Mark python 3.14 as supported. - Remove direct dependency on numpy. - Remove dependency on python-dotenv (note: .env files are no longer loaded automatically). - Remove onnxruntime<=1.20.1 Windows pin. See all CHANGELOGs here: https://github.com/google/magika/blob/python-v1.0.2/python/CHANGELOG.md#102---2026-02-25 | Low | 2/27/2026 |
| cli/v1.0.2 | ## Install magika 1.0.2 ### Install prebuilt binaries via shell script ```sh curl --proto '=https' --tlsv1.2 -LsSf https://github.com/google/magika/releases/download/cli/v1.0.2/magika-installer.sh | sh ``` ### Install prebuilt binaries via powershell script ```sh powershell -ExecutionPolicy Bypass -c "irm https://github.com/google/magika/releases/download/cli/v1.0.2/magika-installer.ps1 | iex" ``` ## Download magika 1.0.2 | File | Platform | Checksum | |--------|----------|----------| | | Low | 2/25/2026 |
| python-v1.0.1 | This release marks the first stable release, and the end of the experimental phase. Updated documentation is at the new website: https://securityresearch.google/magika/ See CHANGELOGs here: https://github.com/google/magika/blob/python-v1.0.1/python/CHANGELOG.md#101---2025-10-31. | Low | 10/31/2025 |
| python-v0.6.3 | See changelog at https://github.com/google/magika/blob/python-v0.6.3/python/CHANGELOG.md#063---2025-10-30 | Low | 10/30/2025 |
| cli/v1.0.1 | ## Install magika 1.0.1 ### Install prebuilt binaries via shell script ```sh curl --proto '=https' --tlsv1.2 -LsSf https://github.com/google/magika/releases/download/cli/v1.0.1/magika-installer.sh | sh ``` ### Install prebuilt binaries via powershell script ```sh powershell -ExecutionPolicy Bypass -c "irm https://github.com/google/magika/releases/download/cli/v1.0.1/magika-installer.ps1 | iex" ``` ## Download magika 1.0.1 | File | Platform | Checksum | |--------|----------|----------| | | Low | 10/10/2025 |
| cli/v1.0.0 | ## Install magika 1.0.0 ### Install prebuilt binaries via shell script ```sh curl --proto '=https' --tlsv1.2 -LsSf https://github.com/google/magika/releases/download/cli/v1.0.0/magika-installer.sh | sh ``` ### Install prebuilt binaries via powershell script ```sh powershell -ExecutionPolicy Bypass -c "irm https://github.com/google/magika/releases/download/cli/v1.0.0/magika-installer.ps1 | iex" ``` ## Download magika 1.0.0 | File | Platform | Checksum | |--------|----------|----------| | | Low | 9/12/2025 |
| cli/v0.1.4 | ## Install magika 0.1.4 ### Install prebuilt binaries via shell script ```sh curl --proto '=https' --tlsv1.2 -LsSf https://github.com/google/magika/releases/download/cli/v0.1.4/magika-installer.sh | sh ``` ### Install prebuilt binaries via powershell script ```sh powershell -ExecutionPolicy Bypass -c "irm https://github.com/google/magika/releases/download/cli/v0.1.4/magika-installer.ps1 | iex" ``` ## Download magika 0.1.4 | File | Platform | Checksum | |--------|----------|----------| | | Low | 9/10/2025 |
| cli/v0.1.3 | ## Install magika 0.1.3 ### Install prebuilt binaries via shell script ```sh curl --proto '=https' --tlsv1.2 -LsSf https://github.com/google/magika/releases/download/cli/v0.1.3/magika-installer.sh | sh ``` ### Install prebuilt binaries via powershell script ```sh powershell -ExecutionPolicy Bypass -c "irm https://github.com/google/magika/releases/download/cli/v0.1.3/magika-installer.ps1 | iex" ``` ## Download magika 0.1.3 | File | Platform | Checksum | |--------|----------|----------| | | Low | 9/10/2025 |
| python-v0.6.2 | See changelog at https://github.com/google/magika/blob/python-v0.6.2/python/CHANGELOG.md#062---2025-05-02 | Low | 5/2/2025 |
| python-v0.6.1 | This release includes breaking changes from the last stable release, 0.5.1. See changelog at https://github.com/google/magika/blob/python-v0.6.1/python/CHANGELOG.md for more information about the changes, the new features, and a migration guide. | Low | 3/19/2025 |
| python-v0.6.1-rc3 | See changelog at https://github.com/google/magika/blob/python-v0.6.1-rc3/python/CHANGELOG.md#061-rc3---2025-03-17 | Low | 3/17/2025 |
| python-v0.6.1-rc2 | See changelog at https://github.com/google/magika/blob/python-v0.6.1-rc2/python/CHANGELOG.md#061-rc2---2025-03-11 | Low | 3/11/2025 |
| python-v0.6.1-rc1 | See changelog at https://github.com/google/magika/blob/python-v0.6.1-rc1/python/CHANGELOG.md#061-rc1---2025-02-04 | Low | 2/4/2025 |
