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 🙏

© 2025 – Pkg Stats / Ryan Hefner

markdown-to-ansi

v1.0.0

Published

Convert markdown to ansi with support of hyperlinks

Downloads

3,987

Readme

markdown-to-ansi

Convert markdown to ansi with support of hyperlinks.

npm node Test JavaScript Style Guide Common Changelog

Features

Meant for short snippets of markdown, markdown-to-ansi supports a subset of (GFM) markdown:

  • Inline code
  • Links. If the terminal does not support hyperlinks, only the url is returned.
  • Literal urls. GitHub and npm urls are shortened (see example below).
  • Emphasis and strong
  • Headings
  • Thematic breaks (---)

Other markdown is simply returned as markdown (not necessarily as-is because it does go through a parser). Pull requests are welcome to support additional markdown syntax. It's easy to extend because markdown-to-ansi is built on the micromark parser and friends.

Usage

This package is ESM-only.

Given an example.md:

## Links

Literal url: https://example.com
Markdown link: [beep](https://example.com)
With formatting: [`boop`](https://example.com)
PR: https://github.com/vweevers/markdown-to-ansi/pull/1
Commit: https://github.com/vweevers/markdown-to-ansi/commit/1234567
Repo: https://github.com/vweevers/markdown-to-ansi
Package: https://www.npmjs.com/package/markdown-to-ansi

---

## Lists, strong and emphasis

- **foo**
- _bar_
- **_baz_**

And running the following example.js:

import markdownToAnsi from 'markdown-to-ansi'
import fs from 'fs'

const markdown = fs.readFileSync('example.md', 'utf8')
const transform = markdownToAnsi()
const result = transform(markdown)

console.log(result)

Results in:

example screenshot 1

My terminal doesn't support bold, so let me demonstrate custom styles:

const chalk = require('chalk')
const transform = require('markdown-to-ansi')({
  style: {
    thematicBreak: chalk.red,
    emphasis: chalk.underline,
    strong: chalk.red
  }
})

Results in:

example screenshot 2

API

transform = markdownToAnsi([options])

Factory that returns a transform function. Options:

  • stream: stream to detect support of hyperlinks on, defaults to stdout
  • width (number): terminal width, used for thematic breaks, defaults to stream.columns
  • style (object): override one or more styles by providing functions that return a formatted string for:
    • inlineCode
    • heading
    • emphasis
    • strong
    • thematicBreak.

ansi = transform(markdown)

Takes a markdown string, returns a string containing ansi escape sequences.

Install

With npm do:

npm install markdown-to-ansi

License

MIT © Vincent Weevers