Text Extensions
Check if a file or extension is text, and iterate over 300+ known text file types including source code, markup, data formats, and configuration files. Python port of text-extensions npm package.
Features
- Immutable collection of hundreds of known text file extensions
- Fast membership checks using
frozenset - Case-insensitive and dot-aware checks
- Works for both extensions and full file paths
- Supports dotfiles (e.g.,
.gitignore) - Zero dependencies, minimal overhead
Installation
pip install text-extensions
Or using uv:
uv add text-extensions
Usage
Check if an extension is text
from text_extensions import is_text_extension
is_text_extension("txt") # True
is_text_extension(".py") # True (dot-aware)
is_text_extension("JS") # True (case-insensitive)
is_text_extension("png") # False
Check if a file path has a text extension
from text_extensions import is_text_path
is_text_path("document.txt") # True
is_text_path("/path/to/file.PY") # True (case-insensitive)
is_text_path("script.js") # True
is_text_path("image.png") # False
is_text_path(".gitignore") # True (dotfile support)
Access the list of text extensions
from text_extensions import TEXT_EXTENSIONS, TEXT_EXTENSIONS_LOWER
# TEXT_EXTENSIONS is a frozenset of all known text extensions
print(len(TEXT_EXTENSIONS)) # Number of supported extensions
"txt" in TEXT_EXTENSIONS # True
"png" in TEXT_EXTENSIONS # False
# TEXT_EXTENSIONS_LOWER contains all extensions in lowercase
# Useful for case-insensitive lookups without calling .lower() repeatedly
"TXT" in TEXT_EXTENSIONS_LOWER # True (case-insensitive)
Supported Extensions
The package includes support for hundreds of text file extensions, including:
- Source Code: py, js, ts, java, c, cpp, go, rs, rb, php, and more
- Markup: html, xml, md, markdown, json, yaml, yml, and more
- Stylesheets: css, scss, sass, less, styl, and more
- Configuration: ini, conf, cfg, json, yaml, toml, and more
- Data Formats: csv, tsv, json, xml, sql, and more
- Documentation: txt, md, rst, tex, and more
- Scripts: sh, bash, zsh, fish, bat, cmd, and more
- And many more...
Credits
This package is a Python port of the text-extensions npm package by Sindre Sorhus.
Changelog
See CHANGELOG.md for a detailed list of changes and version history.
Contributing
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct, development setup, and the process for submitting pull requests.
Support
If you find this library useful, please consider:
- ⭐ Starring the repository on GitHub to help others discover it.
- 💖 Sponsoring to support ongoing maintenance and development.
Become a Sponsor on GitHub | Support on Patreon
License
MIT License - see LICENSE file for details.
Author
Y. Siva Sai Krishna
- GitHub: @ysskrishna
- LinkedIn: ysskrishna
Metadata
Release files for text-extensions 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| text_extensions-1.0.1.tar.gz | 17.6 kB | Without provenance | Details for text_extensions-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| text_extensions-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for text_extensions-1.0.1-py3-none-any.whl |
Total release size: 23.4 kB
Release files / text_extensions-1.0.1.tar.gz
| Download URL | text_extensions-1.0.1.tar.gz |
|---|---|
| Size | 17.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
394f9be5bca7e6443f3a22bb5363e4176913bcdae309a61f9d98123377c1a0f9
|
|
BLAKE2b-256 checksum How to use checksums |
c7789d951142da04f670ac269513df6fc86adfbf4bc42d73df94e23c75b09405
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / text_extensions-1.0.1-py3-none-any.whl
| Download URL | text_extensions-1.0.1-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b1cee6dc220f13d4cdc347158fd77d7db360d8ad8caf52b6a5e4ebc8002ade55
|
|
BLAKE2b-256 checksum How to use checksums |
98b15376dd65e6bcd473b215c73ebbbe096edb0065beb6ed4bb6be3b7b45efc0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for text-extensions 1.0.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.