npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tree201/markdansi

v0.4.4

Published

Tiny dependency-light markdown to ANSI converter.

Downloads

287

Readme

Markdansi 🎨 — Markdown, dressed for the terminal.

CI npm Node.js License

Markdansi renders GitHub Flavored Markdown as wrapped ANSI output for Node.js terminals. Use it as a CLI, an ESM library, or an append-only streamer for incremental output.

Install

Markdansi requires Node.js 22 or newer. Run the CLI without installing it:

npx markdansi README.md

Add the CLI and library to a project with your package manager:

npm install markdansi

Quick start

Pipe Markdown to the CLI and it writes rendered output to stdout:

$ printf '# Hello, **terminal**\n\n- wraps Markdown\n- formats tables\n' | npx markdansi --no-color --width 50

Hello, terminal
- wraps Markdown
- formats tables

Omit --no-color for ANSI styles and OSC-8 links when the terminal supports them.

Releasing the fork

Run releases only from a clean main branch:

pnpm release -- patch

The release command updates package.json and CHANGELOG.md, runs the complete pnpm build quality gate, commits release: vX.Y.Z, creates the tag, and pushes main plus the tag. The tag triggers npm OIDC publishing. Explicit versions and major / minor are also supported.

Use as a library

import { render } from "markdansi";

const output = render("# Hello **terminal**", { width: 60 });
process.stdout.write(output);

Markdansi ships as ESM. CommonJS callers can load it with import("markdansi").

createRenderer() binds options for repeated renders, while strip() produces plain text without ANSI or hyperlinks:

import { createRenderer, strip } from "markdansi";

const renderNarrow = createRenderer({ width: 48, theme: "dim" });
console.log(renderNarrow("## Status\n\nEverything is **ready**."));
console.log(strip("Read [the docs](https://example.com)."));

Stream incremental Markdown

createMarkdownStreamer() emits completed fragments without cursor movement or in-place redraw. Regular lines are emitted as they arrive; fenced code blocks and tables are buffered until they are complete.

import { createMarkdownStreamer, render } from "markdansi";

const streamer = createMarkdownStreamer({
  render: (markdown) => render(markdown, { width: process.stdout.columns ?? 80 }),
  spacing: "single",
});

process.stdin.setEncoding("utf8");
process.stdin.on("data", (chunk) => process.stdout.write(streamer.push(chunk)));
process.stdin.on("end", () => process.stdout.write(streamer.finish()));

This mode is intended for append-only output such as streamed model responses and terminal logs.

Customize rendering

Built-in themes are default, dim, bright, solarized, monochrome, and contrast. A custom theme can set named, hex, or ANSI-256 foreground and background colors.

| Area | Main options | | --------------- | ----------------------------------------------------------------------------- | | Layout | width, wrap, listIndent, quotePrefix | | Color and links | color, hyperlinks, theme | | Tables | tableBorder, tablePadding, tableDense, tableTruncate, tableEllipsis | | Code blocks | codeBox, codeGutter, codeWrap, highlighter |

Markdansi does not bundle a syntax highlighter. Pass a highlighter(code, language) hook when you need one; see Syntax highlighting for a Shiki integration.

CLI and behavior reference

The CLI accepts Markdown from a positional file, --in, or stdin, and writes to stdout unless --out is set. See the CLI reference for every flag and the library reference for exports, options, rendering behavior, and edge cases.

Related

Looking for a native Swift implementation? See Swiftdansi.

Development

The build runs formatting, linting, type checking, tests, and compilation:

pnpm install --frozen-lockfile
pnpm build

License

MIT