Skip to main content

A zero-dependency Python library for ANSI coloring and smart CLI icons with automatic environment detection

Project description

RazTint

PyPI Version PyPI Downloads Python Versions License Zero Dependencies

A zero-dependency Python library for ANSI coloring and smart CLI icons that automatically adapt to your environment.

Preview

RazTint preview: Nerd Font, Unicode, and ASCII icon modes with colored and styled output examples


Table of Contents


Why RazTint?

💡 RazTint believes terminal styling should be zero-friction: no dependencies, no configuration files, no guessing the user's environment. It figures out the rest so you can focus on your CLI logic.

  • Zero dependencies — Python ≥ 3.10 standard library only
  • Smart icons — Nerd Font → Unicode → ASCII fallback, with environment-aware detection
  • Cross-platform behavior — Linux, macOS, and Windows, including CI
  • Minimal setup — import and use; detection is cached and fast

Features

  • 🎨 Full ANSI 16-color foreground and background support
  • 🌈 Extended colors: 24-bit True Color (rgb, hex_color) and 256-color (color256)
  • ✨ Text styles: bold, dim, italic, underline, strikethrough
  • 🔍 Status icons with three-tier fallback and environment-aware detection
  • 🖌️ paint() — one call for color, background, styles, and icons
  • 🎯 Intents — semantic presets (success, danger, warning, …)
  • 🔒 Redaction — mask secrets in logs before printing
  • 💡 Fully type-hinted public API (py.typed, IDE autocompletion)
  • ⚙️ Configurable via environment variables (NO_COLOR, RAZTINT_FORCE_COLOR, …)

Requirements

  • Python 3.10 or newer

Installation

pip install raztint

From source:

git clone https://github.com/razbuild/raztint.git
cd raztint
uv sync

Quick Start

from raztint import ok, paint

print(f"{ok()} File saved.")
print(paint("Connection failed.", color="red", icon="err"))

# Semantic intents
print(paint("Deployment complete.", intent="success"))

# Mask secrets before logging
print(paint("password=1234", intent="debug", redact=True))  # password=****

Standalone redaction without formatting:

from raztint import redact

print(redact("password=supersecret api_key=ghp_abc123"))
# password=**** api_key=****

See Getting Started for more examples. Icon output depends on the detected mode: Nerd Font, standard Unicode, or ASCII.


Documentation

Guide Description
Getting Started Functional usage, paint(), and the tint instance
API Reference Colors, styles, icons, and RazTint class methods
Intents Semantic presets for common CLI messages
Security & Redaction Masking tokens, credentials, and custom rules
Icons & Detection Icon modes and environment/font/color detection logic
Configuration Environment variables and runtime toggles
Development Local setup, tests, and linting
Tutorial Philosophy, detection walk-through, and best practices

Examples

Script Description
examples/basic_usage.py Colors, styles, icons, intents, and redaction in one script
examples/format_text_demo.py Full paint() showcase — every color, style, and icon mode
examples/real_world_cli.py Simulated file-processor CLI showing real integration patterns

Extended Colors

RazTint supports 24-bit True Color and 256-color mode via raw ANSI escape sequences — no extra dependencies.

from raztint import rgb, hex_color, color256
from raztint import bg_rgb, bg_hex_color, bg_color256

# True Color foreground
print(rgb("This is orange text", 255, 100, 50))
print(hex_color("Same orange via hex", "#FF6432"))

# True Color background
print(bg_rgb("Orange background", 255, 100, 50))
print(bg_hex_color("Same via hex", "#FF6432"))

# 256-color
print(color256("Orange via 256 palette", 208))
print(bg_color256("Background 256", 208))

# Compose freely with existing helpers
from raztint import bold
print(bold(rgb("Bold True Color text", 0, 200, 0)))
print(rgb(bg_color256("White on orange bg", 208), 255, 255, 255))

Terminal support: True Color requires a terminal that supports TERM=xterm-256color or similar. NO_COLOR and RAZTINT_FORCE_COLOR are respected.


Known Limitations

  • Python 3.10+ — older versions are not supported.
  • Font detection relies on OS toolsfc-list (Linux), system_profiler (macOS), PowerShell (Windows). Set RAZTINT_SKIP_SYSTEM_FONT_SCAN=1 in sandboxed environments.
  • Strict NO_COLOR compliance — when NO_COLOR is set, all colour output is suppressed regardless of other settings.

Contributing

PRs and issues are welcome. If you find a bug or want to add a feature, open an issue first so we can discuss it. See CONTRIBUTING.md for setup and guidelines.


License

MIT License

Made by RazBuild

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

raztint-0.8.1.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

raztint-0.8.1-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file raztint-0.8.1.tar.gz.

File metadata

  • Download URL: raztint-0.8.1.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.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}

File hashes

Hashes for raztint-0.8.1.tar.gz
Algorithm Hash digest
SHA256 8ad543cc2827031007422cb47d63f531e2629451b53bdcf7fe02f7de4bf2d013
MD5 a3da77180001e4220c5b34be6847ab42
BLAKE2b-256 11af1eec5a42f0fa5b7abd4af00170377c13e3129a4ac8502b6ebf0f824dd628

See more details on using hashes here.

File details

Details for the file raztint-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: raztint-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 22.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.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}

File hashes

Hashes for raztint-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f340118a43d70b30d29806837c6660cd9613a6962d21ee8d8626a68ead8ab69b
MD5 4b192561eb3396e611dbaf8fb242898b
BLAKE2b-256 ca0cb989912c99cc3142c150764df83ab2b2ed771377576f3ae25cfd1fbdb0cf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page