filetype
Infer file type and MIME type of any file/buffer. No external dependencies.
Decision gist · record as of 2026-08-14
Yes, with conditions. Install if you need lightweight, dependency-free file type detection and can tolerate aging maintenance. The library is stable (Production/Stable classifier), has no known vulnerabilities, and handles a wide range of formats. However, the last release was 2022-11-02 with no recent commits, so it may not support the newest file formats or receive bug fixes promptly. Best suited for established use cases (common image, video, audio, archive, and document formats) rather than cutting-edge format support.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low install friction: pure Python, no compiled dependencies or external libraries.
- Maintenance is aging—last release was 2022-11-02 and the repository shows no recent commits, though it remains archived=false and has accumulated 770 stars.
License · maintenance · safety
MIT (permissive) — MIT license (permissive) means you can use this freely in commercial and private projects with minimal restrictions.
last release 2022-11-02 (1381 days) · last repo commit 2025-05-02 · 770 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 45,723,141 downloads/mo, #618 on PyPI
Alternatives
Verify before relying
pip install filetype
import filetype
kind = filetype.guess('sample.jpg')
if kind:
print(kind.extension, kind.mime)- Whether the package still handles modern file formats reliably given the aging maintenance status.
- Performance characteristics when processing large files or many files in sequence.
What it is and what it does
filetype is a lightweight Python library that identifies file types and MIME types by reading the magic number signatures (file headers) at the start of a file or byte buffer. It requires only the first 261 bytes of a file, making it efficient even for large files. The library is pure Python with no external dependencies—no C extensions, no libmagic bindings—and works across platforms.
You use it to determine what kind of file you're dealing with: image formats (jpg, png, webp, heic, avif, etc.), video formats (mp4, mkv, webm, mov, etc.), audio formats (mp3, flac, wav, aac, etc.), archives (zip, tar, gz, 7z, rar, etc.), documents (pdf, docx, xlsx, pptx, etc.), and fonts. It can also discover files by extension, MIME type, or category (image, video, audio, etc.), and supports custom type matchers for non-standard formats.
Use it for
- Validate uploaded files in web applications by checking actual file type rather than trusting user-supplied extensions.
- Automatically categorize media files in batch processing pipelines by kind (image, video, audio) without external tools.
- Identify archive formats before extraction to route them to the correct decompression handler.
- Detect file type from byte buffers (e.g., from network streams or database BLOBs) without writing to disk.
- Build file discovery tools that group or filter files by MIME type or category across mixed directories.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, with conditions.
Install if you need lightweight, dependency-free file type detection and can tolerate aging maintenance. The library is stable (Production/Stable classifier), has no known vulnerabilities, and handles a wide range of formats. However, the last release was 2022-11-02 with no recent commits, so it may not support the newest file formats or receive bug fixes promptly. Best suited for established use cases (common image, video, audio, archive, and document formats) rather than cutting-edge format support.
Install
filetype on PyPI
Before you install
Low install friction: pure Python, no compiled dependencies or external libraries. Maintenance is aging—last release was 2022-11-02 and the repository shows no recent commits, though it remains archived=false and has accumulated 770 stars.
License in practice
MIT license (permissive) means you can use this freely in commercial and private projects with minimal restrictions.
Quickstart
pip install filetype
import filetype
kind = filetype.guess('sample.jpg')
if kind:
print(kind.extension, kind.mime)
Verify before relying
- Whether the package still handles modern file formats reliably given the aging maintenance status.
- Performance characteristics when processing large files or many files in sequence.
Package facts
| License | MIT permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Aging 1,381 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 45,723,141 / month, #618 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableEnvironment :: ConsoleEnvironment :: Web EnvironmentIntended Audience :: DevelopersIntended Audience :: System AdministratorsLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: SystemTopic :: System :: FilesystemsTopic :: Utilities |
Evidence: filetype-1.2.0-py2.py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “mime type inference”
- filetypeInfers file type and MIME type by examining magic number signatures…
- zope.contenttypeGuesses MIME types from filenames and body data, parses MIME type…
- python-mimeparseParses and matches MIME types against media-ranges according to RFC…
Give your agent the search over MCP, or paste the wish link into any chat.
More System packages
Provides a platform-independent file locking mechanism to coordinate access to files across processes and threads.
Distro provides a reliable, machine-readable API to query the Linux or BSD distribution name, version, codename, and other OS platform details, replacing Python's deprecated `platform.linux_distribution` function.
Install it if you need to detect or report the Linux/BSD distribution your code runs on.
psutil retrieves real-time information about running processes and system resources (CPU, memory, disks, network, sensors) across multiple operating systems, enabling system monitoring, process profiling, and resource management.
Pexpect spawns and controls interactive console applications by sending input and matching output patterns, automating tasks that would otherwise require manual interaction.
Provides asynchronous file I/O operations for asyncio programs, with automatic selection of the best available backend (io_uring, libaio, thread-based, or pure Python) depending on your system.
Portalocker provides cross-platform file locking with support for exclusive and shared locks, plus Redis-based distributed locks and process-aware PID file locking.
Install it if you need file or process coordination; the optional extras (pywin32, redis) are only required for specific lock types.
See also magika · puremagic · python-magic · cigam · typecode · python-magic-bin · file-magic · libmagic · crewai-files · mediatype