mrkeyoor.com_
Wed 09 Sept 16:54 UTC
Dev Toolsevaluationupdated 09 Sept 2026

magika review

Magika identifies a file's content type from its bytes instead of trusting the filename or extension. It uses a small machine-learning model behind a Rust command-line tool and Python, Rust, JavaScript, and work-in-progress Go bindings, returning a stable label plus confidence and type metadata for routing files through other systems.

trackingstars / 7d
Verdict

Our Magika Go run installed 2 packages in 7 seconds, built in 12 seconds, and passed 2 of 2 tests in 14 seconds. The CLI or Python package is the safer default for most users because the Go binding still needs cgo, ONNX Runtime, linker flags, and separately packaged assets. Use Magika as a fast routing signal, then keep format parsers and security scanners responsible for final trust decisions.

We ran it

Lab card: what happened when we ran magikaScreenshot of magika (securityresearch.google/magika)
Install✓ · 7s2 packages
Build✓ · 12s
Tests✓ · 14s2 passed · 0 failed of 2 (go test)
Repo578 files~22,586 lines of source · 98.2 MB · 18 CI workflows

Answers from our run

Does magika build from source?

Dependencies installed in 7 seconds (2 packages), and the build succeeded in 12 seconds. We cloned commit 174e00c into a clean Debian container with 3 CPUs and no project-specific setup.

Do magika's tests pass?

Yes: 2 of 2 passed when we ran the project's own test command (go test). Some failures need services or credentials a bare container does not have.

Who should not use magika?

Pure-Go deployments that prohibit cgo or native shared libraries: the Go binding requires cgo and the ONNX Runtime C API.

What are the alternatives to magika?

file, PolyFile, Apache Tika. Our Magika Go run installed 2 packages in 7 seconds, built in 12 seconds, and passed 2 of 2 tests in 14 seconds.

Setup4/5CLI installs are simple; Go needs cgo, ONNX Runtime, and assets
Docs5/5Clear model, confidence, output, binding, and integration guidance
Community5/518,508 stars, a same-day push, and active issue triage
Maturity4/5Stable CLI and Python releases; Go remains work in progress

Who it’s for

Security and upload pipelines that need a first-pass content label before choosing a scanner or parser.
Developers distinguishing source code, documents, archives, media, and executables without trusting extensions.
CLI users who want recursive scans plus JSON or JSONL output.
Go teams that can ship cgo, ONNX Runtime, and Magika's model assets with their application.

Who it’s NOT for

Pure-Go deployments that prohibit cgo or native shared libraries: the Go binding requires cgo and the ONNX Runtime C API.
Applications that need detailed format metadata: Magika labels an ELF or PE file but the FAQ says it does not report finer details such as static versus dynamic linking.
Pipelines expecting every niche format to receive a specific label: the current model supports a defined set, and open requests include GNU MO and GGUF files.
Security controls that cannot tolerate a confident misclassification: open reports include HEIF identified as MP4 and a shell script identified as Tcl.
Teams treating MIME type as the permanent API contract: the project recommends integrating on its simple label because MIME mappings and verbose descriptions can change.
Go users expecting the same release status as the main CLI: the root README still marks the Go binding as work in progress.

Setup reality

Our Go sandbox install succeeded in 7 seconds with 2 packages. The build passed in 12 seconds, and go test passed all 2 tests in 14 seconds. The full checkout contained 578 files, roughly 22,586 source lines, and occupied 98.2 MB.

The measured Go path lives under ./go/. Real inference needs cgo, the ONNX Runtime C library, Magika assets, a model name, build tags, and external linker flags. It needs no hosted credential or GPU.

CLI users have easier routes through Homebrew, pipx, Cargo, or signed release binaries. Go includes a sample Dockerfile, but consumers still own the native-library path and model asset packaging.

Standard v3.3 returns 216 high-level file labels

Magika identifies content from file bytes rather than a name or extension. The standard v3.3 model's documented tool output contains 216 labels spanning source code, documents, archives, media, executables, fonts, and several generic results. Empty files, directories, symbolic links, and inputs too small for the model take separate heuristic paths. A successful result includes a simple label, human description, MIME type, group, text flag, possible extensions, and the model's confidence score.

Our full checkout measured 578 files, roughly 22,586 lines of source, and 98.2 MB. The repository contains a Rust CLI and library, a Python package, an experimental JavaScript package, model assets, a website, and a Go binding marked work in progress. The command line can scan many paths recursively and return plain text, custom fields, JSON, or JSONL. For application code, the project recommends using its simple label rather than parsing the prose description or treating MIME type as stable.

A few 2 KB slices make classification fast and imperfect

The documentation says the model usually inspects up to 2 KB from selected parts of a file instead of reading the whole payload. Google reports training and evaluation on about 100 million samples across more than 200 content types, roughly 99 percent average precision and recall on its test set, and about 5 ms inference after model loading on one CPU. Those are project claims from its data and method, not numbers from our Go sandbox.

Limited sampling is also the design tradeoff. Per-type thresholds decide whether Magika returns the model's specific guess or falls back to generic text or unknown binary data. Version 1.1.0 issue 1413 shows a 1,560-line shell script classified as Tcl after syntax from embedded Awk appeared near the sampled tail. Issue 1414 reports scripts with long licence headers or POD documentation returning unknown. A label is a routing hint, not proof that the rest of the file matches it.

What happened when we ran it

Our sandbox entered ./go/ at commit 174e00c and installed 2 packages in 7 seconds. The build passed in 12 seconds. go test then completed in 14 seconds with 2 passed and 0 failed out of 2. The run used a fresh Go 1.24 Debian container with 3 CPUs and 8 GB of RAM. The repository scan found 18 CI workflow files and no top-level tests directory.

Those 2 tests are a small signal for a project with 578 files. The result confirms that the detected Go target installed, compiled, and passed its available lab command in our stated environment. It does not reproduce the README's accuracy, 5 ms inference, or large-scale Google deployment claims. We did not measure classification speed or feed a file corpus through the model, so this review makes no independent accuracy or throughput claim.

The Go binding adds cgo and ONNX Runtime to deployment

Go users create a scanner with an assets directory and model name, then scan a byte reader. The example uses the cgo and onnxruntime build tags, external link mode, and a library search path for ONNX Runtime. The runtime and Magika assets must already be accessible. A sample Dockerfile shows one way to assemble the C library, model, and Go CLI, but the host application still owns native library discovery and asset updates.

The measured Go setup added only 2 packages and built in 12 seconds, which can hide that production requirement. Teams avoiding native dependencies should call the Rust CLI as a separate process or choose another detector. Other users have lower-friction install paths: pipx, Homebrew, a shell installer, Cargo, and platform archives. No API key, hosted service, or GPU is required for local classification, and the browser demo runs the JavaScript model on the user's device.

Three prediction modes expose the precision tradeoff

Magika offers high-confidence, medium-confidence, and best-guess modes. Thresholds vary by content type because an 80 percent score does not mean the same thing for every class. High-confidence returns fewer specific identifications in exchange for stricter acceptance, while best-guess always exposes the model choice. Automated systems should consume the final output label, log the score and raw model label for diagnosis, and decide how generic results flow through later scanners.

Passing 2 Go tests cannot cover all 216 output labels or hostile file constructions. Open issue 1439 reports a HEIF image identified as MP4 by CLI 1.1.0. Issue 1430 shows GGUF model files returning unknown or unrelated low-confidence guesses, while issue 1421 requests GNU MO support. These reports do not erase the project's published aggregate results. They show why a production pipeline needs representative fixtures, a fallback detector, and explicit handling for unknown results.

The April CLI release trails active September development

GitHub recorded 18,508 stars, 165 combined issues and pull requests, and a last push on September 9, 2026. The latest fixed release is cli/v1.1.0, published April 24, with prebuilt archives for major desktop platforms and GitHub artifact attestations. Python 1.0.2 shipped in February. Same-day repository activity and issue updates show continuing work even though the most recent CLI tag is several months old.

The 18 CI workflows, active content-type fixture request, and detailed model changelog support a mature maintenance process. Open Go issue 1444 reports possible C allocation and error-path leaks in the ONNX wrapper, which deserves attention from long-lived Go services. For a new integration, start with the stable Rust CLI or Python package, pin the model version, record generic results, and test the exact file families your system receives before allowing the label to choose a privileged parser.

Alternatives

ProjectWhat it isPick it when
fileThe classic libmagic-based utility that matches file content against a maintained magic database.pick this instead when signature-based identification, wide operating-system availability, and no ML runtime matter most.
PolyFileA pure-Python libmagic alternative with instrumented parsing and an interactive hex viewer.pick this instead when analysts need to inspect file structure and parser boundaries rather than receive one high-level label.
Apache TikaA document toolkit that detects formats and extracts text and metadata from more than a thousand types.pick this instead when content extraction and broad office-document handling matter more than a compact classifier.

What people are saying

  1. [github-trending] google/magika

Sources

  1. Magika repository and README
  2. Magika Go binding guide
  3. Standard v3.3 model outputs
  4. How Magika works
  5. Magika prediction modes
  6. Magika CLI v1.1.0 release
  7. HEIF misdetection report
  8. Go ONNX allocation report

More dev tools reviews

CleanArchitecture · resty · PI-Desktop · chezmoi · iced · Files · the whole board →