ysskrishna logoysskrishna

Text Extensions

Know which paths look like text before you open them. One shared list, no list upkeep.

Built with
PyPI Packages
File & Path Utilities
Python
uv
PyPI
GitHub Actions
Pytest
Details
FreeMIT licenseCreated January 10, 2026Updated November 12, 2026
Share this product

Your upload handler should not start with a wall of extensions you copied once and never updated.

Someone drops a path on you: config, source, markup, or something that only looks innocent. You could open every file and sniff bytes. You could paste another team's extension array into yours and hope it stays current. Either way you spend time on bookkeeping before the real work starts.

Text Extensions is the small library that answers "does this path look like text?" from a shared catalog so you can branch early.

One maintained list beats another hand-rolled whitelist.

What you get

  • A fast yes or no on extensions and paths. Check a bare extension or a full path, with matching that ignores case and handles leading dots the way real filenames do.
  • Hundreds of text types in one place. Source, markup, configs, data formats, and docs sit in a single immutable set aligned with the widely used list this project ports.
  • Cheap lookups at scale. Membership uses a frozen set so repeated checks stay light in hot paths.
  • The raw sets when you need custom rules. Import the full catalog or its lowercase view when you want to layer your own allow or deny logic on top.
  • Nothing extra to install. Zero dependencies and a narrow job: classify by extension and path shape, not by reading file bytes.

Picture your pipeline

An illustrative case: your service accepts user uploads before a parser runs. For each filename you ask whether the path looks like text. Dotfiles such as ignore files count. Mixed-case extensions count. When the answer is no, you reject or route to binary handling without opening the file. When the answer is yes, you still run your encoding checks if you need proof the bytes are really text.

Ready to try it?

Frequently asked questions

How do I check if an uploaded file looks like text in Python?

Pass the extension or the full path to the helpers meant for that job. Matching is case-insensitive and dot-aware, including dotfiles where the whole name behaves like an extension. That is a shape check only. If you must know the bytes are valid text, add encoding detection on top.

What file extensions should I allow for text uploads?

Use the bundled catalog of 300+ known text extensions covering source, markup, stylesheets, configuration, data formats, documentation, and scripts. You can also import the raw sets and trim or extend them for your product rules.

How can I tell if an extension is text without reading the file?

The library classifies from the extension or path alone. It does not open files or detect encodings, which keeps the check cheap before heavier validation.

Are extension checks case-insensitive?

Yes. A lowercase catalog is available when you want case-insensitive membership without calling lowercase on every lookup yourself.

Does a text extension prove the file is UTF-8?

No. Classification is by extension and path shape only. Combine this with parsers or encoding checks when you need certainty about the contents.

Why not just keep my own extension set in the upload handler?

You can, and many teams do until the list rots. This package ships a large, immutable set aligned with the widely used list this project ports, plus helpers so you are not maintaining another copy in every repo.

How do I install it?

It targets Python 3.8 and up and is published on PyPI as text-extensions. Setup details live on the GitHub repository.

Is it free?

Yes. It is open source under the MIT license.

Continue exploring

ProductBinary Extensions

Binary Extensions

Know which paths look binary in Python, from a curated list of 250+ extensions with no extra dependencies.
File & Path Utilities
PyPI Packages
Python
uv
ProductVideo Extensions

Video Extensions

A fast, honest first filter when a filename might be video.
File & Path Utilities
PyPI Packages
Python
uv
ProductUnused Path

Unused Path

Stop overwriting downloads and exports. Get the next free filename, browser style.
File & Path Utilities
PyPI Packages
Python
uv
ProductStrip BOM

Strip BOM

Invisible UTF-8 marks should not break your parsers, CSV headers, or string checks.
Text & Data Conversion
File & Path Utilities
PyPI Packages
Python
ProductSocial Links

Social Links

Users paste messy profile links. One Python library turns them into clean, comparable URLs.
PyPI Packages
Python
uv
PyPI
ProductNested Utils

Nested Utils

Deep JSON and config paths, one string, no guard maze.
PyPI Packages
Python
uv
PyPI