--- id: typecode version: "30.2.0" license: Apache-2.0 license_treatment: permissive maintenance: active --- # typecode — Comprehensive filetype and mimetype detection using libmagic and Pygments. License: permissive · Maintenance: active · Downloads: 127.4K/mo ## What it is and what it does TypeCode is a file type and MIME type detection library that wraps libmagic and Pygments to identify file formats. It started as a library within scancode-toolkit and provides a unified interface for comprehensive filetype detection across Linux, Windows, and macOS. The package supports multiple installation modes: the [full] extra bundles libmagic binaries for immediate use, while the minimal install expects libmagic to be provided by the system, environment variables, or a plugin. It integrates with the plugincode system to allow custom libmagic providers, making it flexible for environments with non-standard library locations. Use it for: - Identify file types in batch processing pipelines without relying on file extensions. - Determine MIME types for web servers or content management systems handling user uploads. - Integrate file type detection into security scanning or compliance tools. - Classify documents by format in archival or document management workflows. - Detect and handle PDF and other structured formats via pdfminer.six integration. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Detects file types and MIME types using libmagic and Pygments, with support for multiple detection methods and optional system or bundled libmagic libraries. Yes. Active maintenance, production-stable status, low install friction, no known vulnerabilities, and permissive licensing make it a solid choice. Install with [full] for immediate use, or [minimal] if your environment already provides libmagic 5.39. Best suited for projects needing reliable file type detection beyond filename inspection. ## Install pip install typecode uv add typecode poetry add typecode ## Installing typecode Before you install: Low install friction with a pure Python wheel. Actively maintained with recent commits and production-stable status. Five runtime dependencies including attrs, binaryornot, commoncode, pdfminer.six, and plugincode. License in practice: Apache-2.0 permissive license allows commercial and private use with minimal restrictions—suitable for most projects. Quickstart: pip install typecode from typecode import identify result = identify.identify_file('path/to/file') Requires libmagic 5.39 available either via the [full] extra, system PATH, environment variables (TYPECODE_LIBMAGIC_PATH, TYPECODE_LIBMAGIC_DB_PATH), or a typecode-libmagic plugin. Verify before relying: - Whether the package's API surface and typical workflows are well-documented beyond the README. - Performance characteristics when processing large batches of files or unusual formats. - Specific accuracy or edge-case behavior compared to direct libmagic or Pygments use. ## Package facts - License: Apache-2.0 (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 127.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags file type detection, mime type detection, libmagic wrapper, file format identification, magic number detection, filetype classifier, file-identification, libmagic-wrapper [View on SkillFed](https://skillfed.io/packages/typecode) · [View on PyPI](https://pypi.org/project/typecode/)