python-magic
Python interface to libmagic for file type identification.
Pricing
Free tier
Flat rate
Adoption
→StableLicense
Open Source
Data freshness
Aging · Jun 8, 2026Overview
What is python-magic?
Provides a Python interface to the libmagic library, enabling developers to identify file types based on their content. This tool is essential for applications that need to handle various file formats and ensure correct processing.
Key differentiator
“python-magic offers precise and reliable file type identification through its Python interface to libmagic, making it an indispensable tool for developers dealing with diverse file formats.”
Capability profile
Capability Radar
Honest assessment
Strengths & Weaknesses
↑ Strengths
↓ Weaknesses
Relies on libmagic, which may not recognize less common or proprietary file formats.
Analyzing the content of very large files can be slow and resource-intensive.
libmagic signatures are updated periodically, potentially missing newer or less common file formats.
Setting up and maintaining custom magic files requires detailed knowledge of the libmagic format and structure.
Fit analysis
Who is it for?
✓ Best for
Developers working on file processing systems who need accurate file type identification.
Security analysts needing to identify and categorize various file types for analysis.
✕ Not a fit for
Applications requiring real-time, high-performance file type detection in extremely large datasets.
Projects that require a web-based UI or cloud-hosted service for file type identification.
Cost structure
Pricing
Free Tier
Available
Open source — free to use
Starts at
$0
Model
Flat rate
Enterprise
None
Performance benchmarks
How Fast Is It?
Ecosystem
Relationships
Next step
Get Started with python-magic
Step-by-step setup guide with code examples and common gotchas.