Ansy¶
ansy
(pronounced ANSI) is a lightweight yet powerful Python library designed to supercharge your command-line output with vivid, expressive styling.
Ansy helps you add colors and styles to your terminal output. It is made for developers who want their CLI apps to look clean, colorful, and easy to read without using heavy libraries or writing complex code.
Why use Ansy?¶
- Multiple Color Modes — You can color your text using
4-bit
,8-bit
, or24-bit
(RGB) color modes. It works on most modern terminals. (Some older terminals may only support4-bit
colors) Learn more - Style Just What You Need — You don’t have to color the whole string. Ansy lets you color just parts of a string, like a word, a number, or a keyword. Learn more
- Gradients & Random Colors — Want your text to pop? You can apply smooth gradients or even use random colors to make your output stand out. Learn more
- Text Formatting — Make your output easier to read with bold, italic, underline, and more formatting options built right in.
- Remove Styling When Needed — Ansy can strip away all colors and styles, giving you clean, plain text when needed. For example, when logging or saving to a file. Learn more
- Common Colors Built In — No need to search for color codes. Ansy gives you easy access to commonly used colors with clear names and hex codes. Learn more
- Zero Dependencies — Written in pure Python, Ansy has no third-party dependencies, making it reliable, portable, and easy to integrate into any project.
- Developer-Friendly API — The code is easy to write and easy to understand. You don’t need to learn anything complicated to use Ansy.
- Very Lightweight — The whole library is under 90 KB, and most of that is helpful stuff like docstrings, color data, and type hints for better code. Ansy stays lean without sacrificing power.