Magika - Google's File Type Detection

Google's internal file type detection system, now open-sourced - a deep learning model that classifies file types with high accuracy, battle-tested on hundreds of billions of files weekly across Gmail, Drive, and Safe Browsing.

What It Is

Magika is a file type identification tool powered by a custom deep learning model developed at Google. Unlike traditional file detection tools that rely on magic bytes or file extensions (both trivially spoofable), Magika uses a trained model that examines file content to determine the actual type. It supports 200+ content types including documents, executables, archives, media, and code.

Google ran Magika internally for years across their highest-scale services: Gmail attachment scanning, Google Drive file classification, and Chrome Safe Browsing - processing hundreds of billions of files per week. The model is small (~1MB) and fast enough for real-time classification, making it practical for both security scanning and content routing.

Source Snapshot

As of 2026-07-04, google/magika is Apache-2.0, default branch main, repo HEAD 7a2299ef064243ac3426c8c1332c9e4d7feed21a, pushed 2026-06-23T09:46:13Z, with 17,229 stars, 1,063 forks, and 150 open issues. PyPI magika latest is 1.0.3; source tags include python-v1.0.3, JavaScript tags through js-v0.3.2, and Rust tags through rust-v0.2.1. Source: GitHub API, git ls-remote, PyPI, 2026-07-04

Relevance to Kevin's Stack

Two use cases connect to Kevin's infrastructure:

Security scanning. Magika complements Brin - Agent Context Security by adding content-aware file type verification. When agents install packages or process uploaded files, Magika can verify that a file claiming to be a .png is actually an image, not a disguised executable. This is especially relevant for the raw/ ingestion pipeline where Kevin drops files from several sources.

Content ingestion routing. For the source-compile automation, knowing the true file type determines which extraction tool to use (MarkItDown for documents, defuddle for HTML, direct read for Markdown). Magika provides reliable detection even when file extensions are missing or wrong.

Signal

  • 6,670 likes, 8,165 bookmarks on @_vmlops thread — Google open-sourced internal file detection used across Gmail, Drive, Safe Browsing. Source: X/@_vmlops, 2026-04-13
  • Google provenance and battle-testing at Gmail/Drive scale provides confidence in accuracy

Timeline