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,794 stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
44 /100 Fair
Development Activity 8
Maintenance 0
Community 68
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
78 /100 Good
Architecture 85
Code Quality 70
Innovation 85
Learning Curve 70

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 13 apps in this directory

Python
89%
Apache 2.0

Apache Airflow

Data Engineering

46,995

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
Python 89%
Updated 4 days ago
Python
59%
Apache 2.0

argilla

AI Development · Data Engineering

5,125

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
Python 59%
Jupyter Notebook 21%
Updated 1 weeks ago
Python
66%
Other

AutoGPT

AI Assistants · Automation · Productivity

187,596

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
Python 66%
TypeScript 33%
Updated 4 days ago
Python
70%
Apache 2.0

GPT Researcher

AI Assistants · Productivity

29,650

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
91
Repo Health
91
Technical
63
Dependency
Built with
Python 70%
TypeScript 18%
Updated 6 days ago
TypeScript
91%
Apache 2.0

Helicone

AI Development · Analytics · Monitoring

6,182

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
70
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 91%
Updated 2 weeks ago
Python
86%
Apache 2.0

knowhere

AI Development · AI Memory · Developer Tools

3,541

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

View details
82
Repo Health
75
Technical
66
Dependency
Built with
Python 86%
HTML 14%
Updated 1 weeks ago
TypeScript
39%
Apache 2.0

Label Studio

AI Development · Data Engineering

28,358

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
TypeScript 39%
JavaScript 27%
Python 25%
Updated 4 days ago
TypeScript
44%
Other

Magic

AI Agents · Automation · Low Code Platforms

5,043

Magic is an enterprise-grade open-source AI agent platform combining a generalist AI agent, workflow engine, IM, and collaborative office system for running an AI-powered digital workforce.

View details
70
Repo Health
79
Technical
65
Dependency
Built with
TypeScript 44%
PHP 32%
Updated 1 months ago
JavaScript
40%
MIT

NoteDiscovery

Knowledge Management · Note Taking · Productivity

2,813

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
JavaScript 40%
Python 32%
HTML 24%
Updated 5 days 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