anser

A low-level parser that converts ANSI escape-sequence text into structured tokens or HTML

Library
npm
v2.3.5
79stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
38/100Needs Attention
Development Activity0
Maintenance32
Community48
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
68/100Good
Architecture62
Code Quality68
Innovation55
Learning Curve85

anser parses strings containing ANSI escape codes — the foreground/background colors, bold/italic/underline styling, and cursor-control sequences terminal programs emit — and turns them into either structured token objects (content plus resolved style) or ready-to-render HTML with inline styles or CSS classes applied. It supports the standard 16/256-color ANSI palettes as well as 24-bit true-color escape sequences.

Because it has no DOM or Node-specific dependency, anser is used both server-side (formatting captured CLI output for a web dashboard or log viewer) and in the browser (rendering colored terminal output inside a web-based console), and is a common dependency behind tools that need to display raw terminal/CI output as readable, styled HTML.

What You Get

  • ansiToJson() - parses ANSI-coded text into an array of structured token objects (content, fg/bg color, style flags)
  • ansiToHtml() - converts ANSI-coded text directly into HTML with inline styles or CSS classes
  • ansiToText() - strips ANSI codes to produce plain text
  • Support for standard 16-color, 256-color, and 24-bit true-color ANSI sequences
  • TypeScript type definitions (lib/index.d.ts) for all exported functions

Common Use Cases

  • Rendering colored CI/build-log output inside a web-based dashboard or log viewer
  • Displaying captured terminal output (from a PTY or child_process) as styled HTML in an Electron or browser-based app
  • Converting stored ANSI-coded log text into plain text for search indexing or plain-text export
  • Building custom terminal-emulator-adjacent tooling that needs a dependency-light ANSI parser rather than a full terminal emulator

Under The Hood

Architecture - The entire implementation lives in a single lib/index.js module exporting an Anser class with static ansiToJson/ansiToHtml/ansiToText methods; internally it tokenizes the input string by scanning for the ESC (\x1b[) sequence prefix, accumulates styling state (foreground/background color, bold/italic/underline flags) across sequences, and emits one token per contiguous run of identically-styled text.

Tech Stack - Plain, dependency-free JavaScript (CommonJS, lib/index.js as both the source and published entry point) with hand-written TypeScript declarations; no build step is required since the published package is the source itself.

Code Quality - The single test/ansi_up-test.js suite (named for the project it was originally derived from) exercises color/style parsing via Mocha, and jshint/jslint provide static linting; the codebase is compact (~630 lines) which keeps its ANSI-parsing edge cases relatively easy to review, though recent commit activity has slowed.

API Design - The three top-level static methods (ansiToJson, ansiToHtml, ansiToText) cover the common conversion needs with a single function call each and an options object for things like class-name-based vs inline-style HTML output, making integration straightforward for both server- and browser-side consumers.

Used by 5 apps in this directory

Go
72%
GPL 3.0

1Panel

Devops · Hosting Control Panel · Monitoring

36,573

The only open-source VPS control panel with native AI agent runtime — deploy websites, Docker stacks, and local LLMs from one web interface.

View details
91
Repo Health
76
Technical
67
Dependency
Built with
Go72%
Vue28%
Updated today
Python
90%
Apache 2.0

Apache Airflow

Data Engineering

46,530

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
66
Dependency
Built with
Python90%
Updated today
TypeScript
84%
Apache 2.0

Continue

Developer Tools · AI Development · AI Code Assistants

35,532

Open-source coding agent for VS Code, JetBrains, and CLI with support for 30+ LLM providers.

View details
87
Repo Health
88
Technical
65
Dependency
Built with
TypeScript84%
Updated today
Go
61%
Apache 2.0

Harness Open Source

Developer Tools · Devops · Code Editors

38,017

A unified open source DevOps platform combining Git hosting, CI/CD pipelines, cloud development environments, and artifact registries in a single self-hosted system.

View details
89
Repo Health
79
Technical
65
Dependency
Built with
Go61%
TypeScript34%
Updated 2 days ago
TypeScript
99%
Other

LobeHub

AI Assistants · Productivity · Automation

81,816

Your Chief Agent Operator — build, schedule, and collaborate with an entire AI team in one self-hostable workspace.

View details
92
Repo Health
81
Technical
72
Dependency
Built with
TypeScript99%
Updated today

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