picocolors
The tiniest, fastest zero-dependency library for ANSI terminal color formatting in Node.js.
Repository Health
Technical Analysis
picocolors is a zero-dependency JavaScript library for adding ANSI color and style formatting to terminal output. At roughly 7 KB installed and benchmarked up to 2x faster than Chalk, it exposes a flat set of formatter functions — colors, background colors, and text styles like bold, italic, and underline — built around a single lightweight closure that correctly handles nested color codes without corrupting output.
Because of its tiny footprint and lack of dependencies, picocolors has become a quiet standard in the Node.js tooling ecosystem: it ships inside PostCSS, Stylelint, SVGO, Browserslist, Vite, and many other widely-used build tools and CLIs, where minimizing node_modules bloat and startup time matters. It supports both CommonJS and ESM consumers, includes TypeScript declarations, respects the NO_COLOR convention, and ships a browser-safe build for bundlers that need one.
What You Get
- Full ANSI color palette - Standard and bright foreground/background color functions (red, green, blue, gray, and their
Bright/bgvariants) covering all 16 base terminal colors. - Text style formatters - bold, dim, italic, underline, inverse, hidden, strikethrough, and reset functions for styling terminal text beyond color.
- Nested-formatting safety - A
replaceClosemechanism that correctly re-opens an outer color code when a nested formatter’s close sequence appears mid-string, avoiding the broken output some competing libraries produce. - Environment-aware color detection - An
isColorSupportedflag computed fromNO_COLOR,FORCE_COLOR,--color/--no-colorflags, TTY status, and CI environment, plus acreateColors(enabled)factory to override it manually. - Dual CJS/ESM and browser builds - A Node-targeted CommonJS module plus a separate
picocolors.browser.jsbuild wired through package.json’sbrowserfield, with bundled TypeScript type declarations.
Common Use Cases
- CLI tool output - Formatting success/error/warning messages, prompts, and diffs in command-line tools without pulling in a heavier dependency tree.
- Build tool and bundler logging - Coloring compiler/bundler console output (as used inside PostCSS, Vite, SVGO, Stylelint, and Browserslist) where install size and cold-start time affect every consumer’s build.
- Drop-in Chalk replacement - Swapping out Chalk in existing codebases to shrink node_modules and speed up script startup, using the documented migration path for chained-call syntax.
- Test runners and dev servers - Highlighting pass/fail output, stack traces, and status messages in local development tooling.
Under The Hood
Architecture picocolors is a single-file, dependency-free module built around one core primitive: a formatter closure that wraps text in ANSI open/close escape codes and handles nested closes via replaceClose (so nesting one color inside another doesn’t prematurely terminate the outer code). All roughly 40 color/style functions are generated by partially applying formatter with different escape sequences, avoiding per-function duplication. The createColors(enabled) factory produces either the real formatters or no-op passthroughs (() => String) based on a boolean, cleanly separating “does the terminal support color” from “format the string” — that separation is essentially the whole architecture. A parallel picocolors.browser.js variant ships for bundlers that need a browser build.
Tech Stack The stack is deliberately plain: dependency-free CommonJS JavaScript targeting Node 6+ and browsers, with a hand-written .d.ts for TypeScript consumers and a browser field in package.json to swap in a browser-safe build for bundlers. There is no build step, transpiler, or runtime dependency — the entire “stack” is authoring conventions (a Prettier config using tabs and no semicolons) and a tests/test.js file run directly by node, reflecting the project’s goal of minimizing everything downstream consumers have to install.
Code Quality The source is under 80 lines with tight, readable logic; naming is clear (isColorSupported, createColors, formatter), and the nested-color-code handling in replaceClose shows real attention to a subtle correctness edge case — nested ANSI codes resetting the wrong style — that several competing libraries get wrong. There’s no linter configuration beyond Prettier, and tests live in a small hand-rolled tests/test.js/tests/environments.js rather than a full test-runner framework, but the terse, single-file source is easy to read end-to-end in one sitting.
API Design The API is a flat object of self-explanatory formatter functions (pc.red(), pc.bold()) plus one power-user escape hatch (createColors(enabled)) for manually controlling color support — there’s no method chaining like Chalk’s, which keeps the mental model simple but requires nesting calls for combined styles (pc.red(pc.bold(text))). The isColorSupported boolean gives consumers an explicit flag to branch on, and because picocolors is a near drop-in replacement for Chalk, migration friction is low and documented directly in the README with a step-by-step “Replacing chalk” guide.
Used by 23 apps in this directory
agentmemory
AI Agents
Persistent memory for AI coding agents — built on the iii engine, it works across Claude Code, GitHub Copilot CLI, Cursor, Gemini CLI, Codex CLI, and any MCP client, so agents stop needing everything re-explained every session.
BrowserOS
Browser · AI Assistants
The open-source agentic Chromium browser with native AI agents, MCP server, and visual workflow automation — your data never leaves your machine.
Bubble Lab
Automation · AI Development
Open-core workflow engine for building AI-powered automations in TypeScript that run natively inside Slack — no context switching required.
Dify
No Code Platforms · AI Development · Developer Tools
Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.
Enclosed
Security
Send end-to-end encrypted notes and files where the server never sees your content — true zero-knowledge sharing.
flue
AI Agents · Developer Tools
Build autonomous AI agents and powerful workflows with a programmable TypeScript harness that gives any model sessions, tools, sandboxes, and durable execution.
HyperFrames
AI Development · AI Design Tools
Turn plain HTML and CSS into deterministic, pixel-perfect MP4 videos — authored by humans or AI agents, rendered by headless Chrome and FFmpeg.
Latitude
AI Agents · Monitoring
Open-source AI agent monitoring that catches what will break next before your users do.
LearnHouse
Learning Management · CMS
Open-source LMS with AI tutoring, real-time collaboration boards, live code execution, and built-in course monetization — self-hosted in minutes.