Tiny ANSI
A minimal, header-only C/C++ library for styled and colored terminal output.
Overview
Tiny ANSI is a lightweight utility for producing clean, expressive terminal output using ANSI escape sequences. It is designed for developers who want full control without introducing unnecessary abstractions or dependencies.
The library supports colored text, background colors, text effects, structured logging, and fatal error reporting, all exposed through a compact and predictable API.
Features
- Foreground and background color output
- Text effects such as bold, underline, and blink
- Formatted printing helpers
- Log levels: INFO, WARN, ERROR, DEBUG, FATAL
- Fatal error handling with file and line reporting
- Automatic ANSI enabling on Windows
- Single-header, zero-dependency design
Example
#define TINY_ANSI_IMPLEMENTATION
#include "tinyansi.h"
int main() {
tansi_init();
tansi_println("System initialized", TANSI_GREEN);
tansi_log(TANSI_WARN, "Low memory condition detected");
tansi_log(TANSI_ERROR, "Configuration file missing");
// tansi_fatal("FATAL", "Unrecoverable error", __FILE__, __LINE__);
return 0;
}
Design Philosophy
Tiny ANSI maps directly to ANSI escape sequences instead of hiding them behind complex layers. This keeps behavior transparent and predictable, which is especially valuable in debugging tools and system utilities.
Being header-only allows the library to be integrated into existing projects without modifying build pipelines or linker settings.
Source Code
The full implementation, documentation, and downloadable header file are available on GitHub: