Skip to main content

FTT Logo File Type Translator (FTT)

A library of helper methods for your Python project to get mime types and general file category

Releases

Available as a pypi package

1.2.0 - Updated sources: 52 new file extensions, and 31 extensions now return a newer upstream mime type (e.g. md is text/markdown, mts is video/mp2t, tsx is text/tsx, ipynb is application/vnd.jupyter, and the StarOffice formats use application/vnd.stardivision.*). File categories now cover 713 extensions, up from 197: many modern formats were added (e.g. svg, heic, avif, md, yaml, odp, xlsm, xz), and an extension with no explicit category now falls back to Image, Audio or Video when its mime type is image/*, audio/* or video/*. ts and html are now Code, sdd is Presentation, asf is Video and gpx is Binary. The package now declares Python 3.6 as its minimum version

1.1.9 - Updated sources, adds many modern file types and updates/eliminates some legacy mime types. File extensions are now treated case-insensitively, matching the .Net and Javascript builds

1.1.8 - Updated sources, adds many modern file types and updates/eliminates some legacy mime types

1.1.7 - Updated sources, optimized generated code to be smaller and to be easier to diff future versions

1.1.5 - Updated sources, adds many modern file types and updates/eliminates some legacy mime types

1.1.3 - Updated sources, Notably the mime type for .js is now text/javascript instead of application/javascript according to the IANA standard specification

1.1.2 - Initial python release

Examples

Install

pip install fttlib

Import the library

from fttlib import FTT

When you need to know the mime type of a file based on its extension.

mimeType = FTT.getMimeType("Path/To/My/File.doc")
print(mimeType)

mimeType = FTT.getMimeType("Path/To/My/File.docx")
print(mimeType)

>  application/msword
>  application/vnd.openxmlformats-officedocument.wordprocessingml.document

When you need to know the file type category of a file based on its extension.

category = FTT.getFileCategory("Path/To/My/File.docx")
print(category)

category = FTT.getFileCategory("Path/To/My/File.jpg")
print(category)

>  FileCategory.Document
>  FileCategory.Image

When you need to know the preferred file extension for a file based on its mime type.

extensions = FTT.getMimeTypeFileExtensions("text/csv")
print(extensions[0])

>  csv

Design

This library is designed along the following tenets:

  • No external dependencies
  • No file system access
  • Small memory footprint
  • Simple static methods (no extension methods and no instantiatable classes)
  • Case-insensitive
  • Portable - works in applications targeting any runtime

File Categories

File media types are broken down into relatively few categories. Sub-categories may be considered in a future release according to information on Wikipedia Here are the guidelines that determine a file's category

  • Archive: any file that can be extracted into several files
  • Audio: any file that can only contain an audio stream
  • Binary: any file that is unclassified or does not have a text representation
  • Code: any file that contains instructions that are compilable or machine-readable
  • Document: any file that is designed for conveying structured information between people
  • Image: any file that can only contain a single image or series of images
  • PDF: any file that is considered a document archive format
  • Presentation: any file that is designed for electronic presentations consisting of a series of separate pages or slides
  • Spreadsheet: any file in which data is arranged in rows and columns and can be manipulated and used in calculations
  • Text: any file that is not classified under another category and is not binary
  • Video: any file that is designed to be a container for a video stream

Known Limitations

  • Even though a mime type to file extension mapping is not necessarily one-to-one, the most common should be returned by the library
  • This library does not provide file sniffing capabilities - in other words, if you have a file and you want to verify the contents are of a specific type, look elsewhere. FTT only uses the file name with an extension. That capability may be added in a future release.
  • The only file categories presently considered are Archive, Audio, Binary, Code, Document, Image, PDF, Presentation, Spreadsheet, Text, and Video. An extension that is not explicitly categorized falls back to Image, Audio or Video when its mime type is image/*, audio/* or video/*, and to Binary otherwise.

Sources

While it is unrealistic to expect this library to provide a comprehensive list with all the file types the world has to offer, it would be nice if we could get close. Generally, if the file type is even remotely common, it is listed in one of the sources. You can submit a bug report for a file type that is missing or that you think should be added. You will have to include a reputable source as well.

Information sources for this library are provided through the following and in order of preference:

  1. http://www.iana.org/assignments/media-types/media-types.xhtml
  2. https://gitlab.freedesktop.org/xdg/shared-mime-info
  3. https://github.com/jshttp/mime-db
  4. http://www.file-extensions.org/

Metadata

Release files for fttlib 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fttlib 1.2.0
File Size Uploaded Provenance Actions
fttlib-1.2.0.tar.gz 69.9 kB With provenance Details for fttlib-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fttlib 1.2.0
File Interpreter ABI Platform Actions
fttlib-1.2.0-py3-none-any.whl Python 3 none any Details for fttlib-1.2.0-py3-none-any.whl

Total release size: 137.3 kB

Release files / fttlib-1.2.0.tar.gz

Download URL fttlib-1.2.0.tar.gz
Size 69.9 kB
Tags Source
SHA-256 checksum
How to use checksums
468ac49bd7e220d8d34fad5322e0493602cec30ef9b3a13a64c57e443b31b0fc
BLAKE2b-256 checksum
How to use checksums
d5f05686767e562189a7286f62622c79281c1c82b83c06d12d9d2de6c6e0f587
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Release files / fttlib-1.2.0-py3-none-any.whl

Download URL fttlib-1.2.0-py3-none-any.whl
Size 67.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
70ef35543802e5014a0aa02c1b786c0d79bbc4b702054d358ec4eef17c6e1ff2
BLAKE2b-256 checksum
How to use checksums
d53e97e36c8a9117beac4f44cbc27076bfea8585ecb8e6bd714fc319a915bc81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Security for fttlib 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fttlib-1.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page