TermTint
A lightweight, zero-dependency Python library for simple colored and styled terminal output.
Why TermTint?
Normally, Python prints unstyled plain text in your terminal:
print("Success!")
If you want colored output, writing raw ANSI escape sequences manually can quickly make your code hard to read:
print("\033[32mSuccess!\033[0m")
TermTint solves this by providing a clean, simple, zero-dependency interface for colored terminal text without the overhead of heavy CLI frameworks:
from termtint import colored
print(colored("Success!", "green"))
Features
- Zero Runtime Dependencies: Uses only the Python standard library.
- Named, RGB & 256 Colors: 8 standard colors, 24-bit True Color (
rgb=(r, g, b)), and 256-color ANSI (color256=n). - 8 Text Styles:
normal,bold,bright,dim,italic,underline,reverse, andstrikethrough. - Modern Windows Support: Native Virtual Terminal support on Windows 10/11.
- NO_COLOR Compliant: TermTint respects
NO_COLORin automatic mode. - Redirect & Stream Aware: TermTint automatically avoids adding ANSI escape sequences when output is redirected to a file or pipe.
- Convenience Helpers: Direct
print_green(),print_rgb(),print_256(), and other function helpers. - Ultra-Lightweight: Minimal runtime overhead and simple code structure.
Installation
Install TermTint via PyPI using pip:
pip install termtint
Quick Start
from termtint import colored, print_green, print_red, print_rgb, print_256
# Standard named colors
print(colored("Operation succeeded", "green"))
print(colored("Disk space low", "yellow", style="bold"))
print(colored("Database error", "red", style="underline"))
# 24-bit True Color (RGB)
print(colored("Custom coral text", rgb=(255, 127, 80)))
print(colored("Styled sky blue", rgb=(135, 206, 235), style="italic"))
# 256-color ANSI
print(colored("Vibrant orange", color256=208))
print(colored("Hot pink", color256=198, style="bold"))
# Convenience print functions
print_green("System online")
print_red("Fatal crash occurred!", style="bold")
print_rgb((255, 165, 0), "Warning: battery at 15%")
print_256(196, "Critical temperature threshold exceeded")
Supported Colors
1. Named Terminal Colors
TermTint supports 8 standard terminal foreground colors:
| Color | Value | Code Example |
|---|---|---|
black |
Black | colored("text", "black") |
red |
Red | colored("text", "red") |
green |
Green | colored("text", "green") |
yellow |
Yellow | colored("text", "yellow") |
blue |
Blue | colored("text", "blue") |
magenta |
Magenta | colored("text", "magenta") |
cyan |
Cyan | colored("text", "cyan") |
white |
White | colored("text", "white") |
Invalid color names raise a ValueError with a helpful error message.
2. RGB / True Color (24-bit)
Pass an (r, g, b) tuple with values from 0 to 255 to rgb=:
print(colored("Custom purple", rgb=(138, 43, 226)))
print(colored("Sunset orange", rgb=(255, 69, 0), style="bold"))
3. 256-Color ANSI
Pass an integer color index (0 to 255) to color256=:
print(colored("Bright red", color256=196))
print(colored("Electric blue", color256=33, style="underline"))
[!NOTE]
color,rgb, andcolor256are mutually exclusive. Specify exactly one color source per call.
Supported Styles
TermTint supports 8 standard text styles:
| Style | Description | Code Example |
|---|---|---|
normal |
Default normal weight | colored("text", "green", style="normal") |
bold |
Bold weight (ANSI 1) | colored("text", "green", style="bold") |
bright |
Bright / bold weight (ANSI 1) | colored("text", "green", style="bright") |
dim |
Faded / lower intensity (ANSI 2) | colored("text", "white", style="dim") |
italic |
Italic text (ANSI 3) | colored("text", "cyan", style="italic") |
underline |
Underlined text (ANSI 4) | colored("text", "blue", style="underline") |
reverse |
Inverted foreground/background (ANSI 7) | colored("text", "yellow", style="reverse") |
strikethrough |
Strikethrough text (ANSI 9) | colored("text", "red", style="strikethrough") |
bold and bright map to the same ANSI escape code (1). All styles combine seamlessly with named colors, RGB, and 256-color output.
Convenience Print Functions
In addition to colored(), TermTint provides direct print functions for fast CLI output:
from termtint import (
print_black,
print_red,
print_green,
print_yellow,
print_blue,
print_magenta,
print_cyan,
print_white,
print_rgb,
print_256,
)
print_green("Success message")
print_red("Error message", style="bold")
print_yellow("Warning message", style="underline")
print_rgb((100, 200, 255), "Custom RGB notice")
print_256(214, "256-color amber alert")
All convenience functions support standard Python print() keyword arguments: sep, end, file, and flush.
Enabling & Disabling Colors
By default, TermTint uses automatic terminal detection. You can explicitly force or disable colors programmatically:
from termtint import enable_color, disable_color, reset_color_state, colored
# Force colors ON (e.g. CLI --color=always flag)
enable_color()
print(colored("Always colored", "cyan"))
# Force colors OFF (e.g. CLI --no-color flag)
disable_color()
print(colored("Plain text only", "cyan")) # Output: "Plain text only"
# Reset back to automatic detection
reset_color_state()
Automatic Terminal & Stream Detection
TermTint automatically detects terminal capabilities using a multi-step check:
- Explicit Toggle: Respects programmatic
enable_color()ordisable_color(). NO_COLORVariable: TermTint respectsNO_COLORin automatic mode (no-color.org).FORCE_COLORVariable: IfFORCE_COLOR=1, colors are forced on in automatic mode.- Destination Stream & TTY Check: If output is redirected (e.g.
python script.py > output.txt) or a file-like stream is supplied (file=f), ANSI escape sequences are avoided automatically. - Dumb Terminal Check: If
TERM=dumb, colors are disabled.
Windows Support
On Windows 10 and 11, TermTint automatically enables Virtual Terminal (VT) processing using standard-library ctypes bindings to the Win32 Console API. If VT mode cannot be enabled, TermTint safely falls back to plain text without crashing.
Colorama Comparison
TermTint is a focused, lightweight alternative for developers who primarily need simple colored terminal output, whereas Colorama provides broader historical ANSI translation.
| Feature / Goal | TermTint | Colorama |
|---|---|---|
| Runtime Dependencies | Zero (Standard Library) | External package |
| Primary Goal | Lightweight colored output | Legacy ANSI translation |
| API Style | Clean functional API | Module constants & stream wrappers |
stdout Patching |
Avoided (pure string format) | Global stream wrapping option |
| Modern Windows 10/11 | Native VT API | Supported |
NO_COLOR Standard |
Supported in auto mode | Not native |
Limitations
TermTint is intentionally small and focused. It is not a full terminal UI framework:
- No progress bars or spinners
- No table or layout formatters
- No cursor movement or screen clearing
- No markdown or syntax highlighting
If you require full TUI widgets or complex terminal graphics, consider tools like Rich or Textual.
Development
Set up TermTint locally:
git clone https://github.com/hasheramin5-cyber/TermTint.git
cd TermTint
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\Activate.ps1
pip install -e ".[dev]"
Run tests and linters:
# Run test suite
pytest
# Run linter
ruff check .
# Run micro-benchmarks
python benchmarks/benchmark.py
Documentation
Full documentation is available in the docs/ directory:
License
TermTint is licensed under the MIT License.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file termtint-0.2.0.tar.gz.
File metadata
- Download URL: termtint-0.2.0.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f2cb4db3afa81c564bc62e691da9878c6d9f68e43535c4cd407e25a2815960f
|
|
| MD5 |
785c86c8f47c516dafb13e7f930e0220
|
|
| BLAKE2b-256 |
c7ad30d3cc8e3b4637b71eb7c2dfda27677e43be7bb63f1167a436450948b51e
|
Provenance
The following attestation bundles were made for termtint-0.2.0.tar.gz:
Publisher:
publish.yml on hasheramin5-cyber/TermTint
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
termtint-0.2.0.tar.gz -
Subject digest:
9f2cb4db3afa81c564bc62e691da9878c6d9f68e43535c4cd407e25a2815960f - Sigstore transparency entry: 2765773289
- Sigstore integration time:
-
Permalink:
hasheramin5-cyber/TermTint@842eac0f55081e601a4e57c971b4dff905675520 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/hasheramin5-cyber
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@842eac0f55081e601a4e57c971b4dff905675520 -
Trigger Event:
release
-
Statement type:
File details
Details for the file termtint-0.2.0-py3-none-any.whl.
File metadata
- Download URL: termtint-0.2.0-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31502fe678f97a398454bc2cc2bcc91fe960df0de50b01958b8293ba3af56fca
|
|
| MD5 |
623ffad3036969006f00de2472ff8749
|
|
| BLAKE2b-256 |
66561f0e214bf4b4b3db1f2e46c7964a7f62644973f57dabafa7d32501fdf781
|
Provenance
The following attestation bundles were made for termtint-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on hasheramin5-cyber/TermTint
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
termtint-0.2.0-py3-none-any.whl -
Subject digest:
31502fe678f97a398454bc2cc2bcc91fe960df0de50b01958b8293ba3af56fca - Sigstore transparency entry: 2765773502
- Sigstore integration time:
-
Permalink:
hasheramin5-cyber/TermTint@842eac0f55081e601a4e57c971b4dff905675520 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/hasheramin5-cyber
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@842eac0f55081e601a4e57c971b4dff905675520 -
Trigger Event:
release
-
Statement type: