# magika

> A tool to determine the content type of a file with deep learning

- **URL**: https://www.freshcrate.ai/projects/magika
- **Author**: pypi
- **Category**: RAG & Memory
- **Latest version**: `cli/v1.1.0` (2026-04-24)
- **License**: Apache-2.0
- **Source**: https://github.com/google/magika/blob/main/python/CHANGELOG.md
- **Homepage**: https://pypi.org/project/magika/
- **Language**: Python
- **GitHub**: 16,420 stars, 963 forks
- **Registry**: pypi (`magika`)
- **Tags**: `content`, `detection`, `learning`, `machine`, `pypi`, `type`

## Description

# Magika Python Package

[![image](https://img.shields.io/pypi/v/magika.svg)](https://pypi.python.org/pypi/magika)
[![NPM Version](https://img.shields.io/npm/v/magika)](https://npmjs.com/package/magika)
[![image](https://img.shields.io/pypi/l/magika.svg)](https://pypi.python.org/pypi/magika)
[![image](https://img.shields.io/pypi/pyversions/magika.svg)](https://pypi.python.org/pypi/magika)
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8706/badge)](https://www.bestpractices.dev/en/projects/8706)
![CodeQL](https://github.com/google/magika/workflows/CodeQL/badge.svg)
[![Actions status](https://github.com/google/magika/actions/workflows/python-build-and-release-package.yml/badge.svg)](https://github.com/google/magika/actions)
[![PyPI Monthly Downloads](https://static.pepy.tech/badge/magika/month)](https://pepy.tech/projects/magika)
[![PyPI Downloads](https://static.pepy.tech/badge/magika)](https://pepy.tech/projects/magika)

<!-- [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/google/magika/badge)](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

## Recent releases

| Version | Date | Urgency | Changes |
| --- | --- | --- | --- |
| `cli/v1.1.0` | 2026-04-24 | High | ## Install magika-cli 1.1.0  ### Install prebuilt binaries via shell script  ```sh curl --proto '=https' --tlsv1.2 -LsSf https://github.com/google/magika/releases/download/cli/v1.1.0/magika-cli-installer.sh \| sh ```  ### Install prebuilt binaries via powershell script  ```sh powershell -ExecutionPolicy Bypass -c "irm https://github.com/google/magika/releases/download/cli/v1.1.0/magika-cli-installer.ps1 \| iex" ```  ## Download magika-cli 1.1.0  \|  File  \| Platform \| Checksum \| \|--------\|--------- |
| `1.0.2` | 2026-04-21 | Low | Imported from PyPI (1.0.2) |
| `cli-latest` | 2026-04-16 | High | 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). |
| `python-v1.0.2` | 2026-02-27 | Low | 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 |
| `cli/v1.0.2` | 2026-02-25 | Low | ## 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 \| \|--------\|----------\|----------\| \| |
| `python-v1.0.1` | 2025-10-31 | Low | 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. |
| `python-v0.6.3` | 2025-10-30 | Low | See changelog at https://github.com/google/magika/blob/python-v0.6.3/python/CHANGELOG.md#063---2025-10-30 |
| `cli/v1.0.1` | 2025-10-10 | Low | ## 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 \| \|--------\|----------\|----------\| \| |
| `cli/v1.0.0` | 2025-09-12 | Low | ## 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 \| \|--------\|----------\|----------\| \| |
| `cli/v0.1.4` | 2025-09-10 | Low | ## 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 \| \|--------\|----------\|----------\| \| |

## Citation

- HTML: https://www.freshcrate.ai/projects/magika
- Markdown: https://www.freshcrate.ai/projects/magika.md
- Dependencies JSON: https://www.freshcrate.ai/api/projects/magika/deps

_Generated by freshcrate.ai. Indexes pypi releases for AI-agent ecosystem packages._
