Colorama

Cross-platform ANSI escape codes that make colored terminal text and cursor control work identically on Windows, macOS, and Linux.

Library
PyPI
v0.4.6
3,795stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
45/100Fair
Development Activity12
Maintenance0
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture85
Code Quality70
Innovation85
Learning Curve70

Colorama solves a specific compatibility problem: ANSI escape sequences for colored terminal text and cursor positioning have always worked on Unix-like systems, but older Windows consoles either ignore or mangle them. Colorama wraps stdout and stderr, detects whether the current console needs help, and either strips the escape codes for safety or translates them into native Win32 console API calls, so code that emits ANSI color codes on Linux and macOS works unmodified on Windows too.

The library exposes two integration styles: a single just_fix_windows_console() call for the common case of simply making native ANSI output stick, and the older, more configurable init()/deinit() pair with autoreset, strip, and convert options for finer control. Its Fore, Back, and Style constants are plain string values, so pairing colorama with the raw ANSI codes it converts, or with a richer coloring library like Rich or Termcolor, requires no extra glue code.

What You Get

  • Cross-platform ANSI support - just_fix_windows_console() makes existing ANSI-emitting code render correctly on Windows consoles with a single function call.
  • Fore/Back/Style constants - colorama.Fore, colorama.Back, and colorama.Style provide ready-made ANSI escape strings for standard and light/bright color variants.
  • Automatic stream detection - AnsiToWin32 inspects whether the wrapped stream is a real Windows console, a redirected file, or a VT-capable terminal, and only converts or strips when actually necessary.
  • Cursor and screen control - Cursor and the underlying ansi module expose escape sequences for cursor movement and clearing the screen or line, translated to native Win32 calls where needed.
  • Zero runtime dependencies - implemented entirely with the Python standard library (ctypes, re, os), so adding colorama adds no dependency-resolution weight to a project.

Common Use Cases

  • CLI tool output - command-line tools use colorama so colored status messages, warnings, and errors render correctly for Windows users without a separate code path.
  • Cross-platform test runners and build scripts - scripts that print colored pass/fail output rely on colorama so CI logs and local terminal output look the same on every OS.
  • Wrapping third-party color libraries - projects pair colorama’s just_fix_windows_console() with libraries like Rich or Termcolor to get styled text generation plus guaranteed Windows compatibility.
  • Legacy console compatibility - applications supporting older Windows terminals without native VT support use colorama’s init() to strip or convert ANSI codes rather than dropping Windows support outright.

Under The Hood

Architecture colorama/init.py exposes init, deinit, reinit, colorama_text, and just_fix_windows_console from initialise.py, plus Fore/Back/Style/Cursor from ansi.py and AnsiToWin32 from ansitowin32.py. initialise.py maintains module-level state (wrapped/orig stdout and stderr, an atexit flag) and decides, via wrap_stream, whether to substitute a stream with an AnsiToWin32-backed proxy. That class inspects the platform and console (winapi_test, enable_vt_processing, tty status) to decide whether writes should be stripped, converted, or passed through untouched, then delegates actual interception to a StreamWrapper whose write() regex-parses ANSI CSI/OSC sequences and maps recognized codes to Win32 calls through a table built in get_win32_calls. Those calls run through winterm.py’s WinTerm, which tracks current foreground/background/style state, and finally through win32.py’s raw ctypes bindings to kernel32. The result is a clean, layered pipeline (sequence generation to interception to state tracking to FFI) with the main wart being colorama’s reliance on Python module-level globals rather than an instantiable object for init/deinit state.

Tech Stack Pure Python 3.9+ with zero third-party runtime dependencies, using only the standard library (ctypes, re, sys, os, atexit, contextlib). Windows integration is implemented via direct ctypes bindings to kernel32.dll functions (GetStdHandle, GetConsoleScreenBufferInfo, SetConsoleTextAttribute, SetConsoleCursorPosition, SetConsoleMode) rather than depending on pywin32, keeping the install footprint minimal. The package builds with hatchling, pulling its version dynamically from colorama/__init__.py, and its test matrix runs via tox across CPython 3.9 through 3.13 and PyPy on Ubuntu, macOS, and Windows in GitHub Actions.

Code Quality The test suite spans several modules covering ANSI code generation, the stream-wrapping/conversion logic, initialization behavior, isatty detection, and Windows terminal state, with the stream-wrapping tests being the most extensive. Tests rely on stdlib unittest with mock-based stubbing of Win32 calls so Windows-specific behavior can be exercised on any OS. The CI matrix actually runs the suite across multiple operating systems and Python versions, giving real cross-platform verification that’s uncommon for a library this size. There are no type hints or a configured linter/formatter anywhere in the codebase, but error handling is narrow and deliberate, catching specific exception types around ctypes and stream operations rather than swallowing errors broadly.

API Design The integration surface is deliberately tiny: a single call to just_fix_windows_console() is enough to make existing ANSI-emitting code Windows-safe, and it was added specifically to replace the more error-prone init() pattern. Fore, Back, and Style are plain string constants that concatenate directly into print() calls, with no wrapper objects or builder API required. The README explicitly discourages requests for additional color-generation helpers, pointing users toward composing colorama with libraries like Rich or Termcolor instead, an unusually disciplined scope boundary for a widely-depended-on package. A documented context manager (colorama_text) and reinit/deinit pair round out the surface without expanding it further.

Used by 12 apps in this directory

Python
90%
Apache 2.0

Apache Airflow

Data Engineering

46,755

Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.

View details
96
Repo Health
89
Technical
64
Dependency
Built with
Python90%
Updated yesterday
Python
59%
Apache 2.0

argilla

AI Development · Data Engineering

5,098

Collaborate on high-quality AI training data with a self-hosted annotation platform built for LLMs, NLP, and multimodal models.

View details
65
Repo Health
81
Technical
61
Dependency
Built with
Python59%
Jupyter Notebook21%
Updated 1 weeks ago
Python
67%
Other

AutoGPT

Automation · Productivity · AI Assistants

187,177

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
66
Dependency
Built with
Python67%
TypeScript32%
Updated today
Python
67%
Apache 2.0

GPT Researcher

Productivity · AI Assistants

29,319

The pioneering open-source autonomous AI agent that conducts deep, multi-source research and produces citation-backed reports exceeding 2,000 words — faster and more reliably than any human researcher.

View details
90
Repo Health
91
Technical
63
Dependency
Built with
Python67%
TypeScript20%
Updated 1 weeks ago
TypeScript
91%
Apache 2.0

Helicone

Monitoring · AI Development · Analytics

6,133

An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.

View details
69
Repo Health
81
Technical
65
Dependency
Built with
TypeScript91%
Updated 1 weeks ago
Python
85%
Apache 2.0

knowhere

AI Development · Developer Tools

2,942

Transform messy, unstructured documents into persistent, navigable memory that AI agents can actually use.

View details
83
Repo Health
75
Technical
69
Dependency
Built with
Python85%
HTML15%
Updated yesterday
TypeScript
38%
Apache 2.0

Label Studio

AI Development · Data Engineering

28,222

Label Studio is an open-source, multi-type data labeling platform that lets teams annotate images, text, audio, video, and time series data with a configurable XML-based UI and export annotations in formats ready for any ML framework.

View details
93
Repo Health
87
Technical
67
Dependency
Built with
TypeScript38%
JavaScript27%
Python25%
Updated today
JavaScript
40%
MIT

NoteDiscovery

Note Taking · Knowledge Management · Productivity

2,777

A self-hosted markdown knowledge base with MCP-powered AI integration, graph views, LaTeX math, and built-in drawing — your notes stay on your server, forever.

View details
80
Repo Health
59
Technical
74
Dependency
Built with
JavaScript40%
Python32%
HTML25%
Updated yesterday
Python
99%
Apache 2.0

Rasa Open Source

AI Assistants · AI Development

21,315

Rasa Open Source is a Python machine learning framework for building contextual, multi-turn chatbots and voice assistants that understand natural language and maintain conversation state.

View details
65
Repo Health
78
Technical
63
Dependency
Built with
Python99%
Updated 1 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search