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

@codebit-programando-solucoes/codebit-md-to-whatsapp

v1.1.11

Published

Converts Markdown written by LLMs into WhatsApp-compatible text

Readme

@codebit-programando-solucoes/codebit-md-to-whatsapp

Converts the Markdown that an LLM writes into text that WhatsApp renders correctly.

import { convertToString, convert, UnsupportedMode } from '@codebit-programando-solucoes/codebit-md-to-whatsapp';

convertToString('**Total:** R$ 4,73 — veja [o produto](https://ex.com/p/1)');
// '*Total:* R$ 4,73 — veja o produto https://ex.com/p/1'

const { text, unsupportedElements } = convert('# Título\n\n---\n\ntexto', { unsupportedMode: UnsupportedMode.Warn });
// text: '*Título*\n\ntexto'
// unsupportedElements: [{ elementType: 'heading' }, { elementType: 'thematicBreak' }]

Convert once, right before sending. The conversion is not idempotent: converting text that is already in WhatsApp format turns *bold* into _italic_.

What is converted

| Markdown | WhatsApp | |------------------------------------------|--------------------------------------------------------------| | **bold**, __bold__ | *bold* | | *italic*, _italic_ | _italic_ | | ***both***, ___both___ | *_both_* | | ~~strike~~ | ~strike~ | | `code` | ```code``` | | fenced block (```, ~~~) | ```code``` (language tag dropped, content never altered) | | - item, + item, * item | * item (indentation kept) | | [text](url) | text url | | ![alt](url) | alt: url | | <https://x.com>, <[email protected]> | the address | | # Heading | *Heading* (reported as unsupported) | | ---, ***, ___ on their own line | removed (reported as unsupported) | | real HTML (<div>…</div>, <br>) | removed with its content (reported as unsupported) | | \*, \_, \~, \`, \[, \# … | the escaped character |

For the [text](url) and <https://x.com> rows, a plain space (visible on purpose, since WhatsApp keeps invisible characters inside the link) is added after the URL when a letter, a digit, or . , ; : ! ? ) directly follows it, so WhatsApp does not link that character. Images, spaces, line breaks, the end of the text and *, _, ~ get no separator.

Anything else passes through untouched, including > quotes and numbered lists.

The parser is deliberately conservative about what counts as markup, so data is not corrupted:

  • Formatting never spans a line break.
  • A *, _ or ~~ needs the usual CommonMark flanking (5 * 3 = 15 and SELECT * FROM t stay as written), and a run between two letters or digits is literal (snake_case, 2*3*4, the *** TXID of a Pix code).
  • Bare http(s):// URLs are kept unchanged, except that a space is inserted after the URL when it is directly followed by a letter, a digit, or . , ; : ! ? ), so WhatsApp does not include that character in the link.
  • < is only HTML when it starts a real HTML tag; 5 < 10, <3, List<String> and <abc123> are text.
  • #, --- and bullets are only recognized at the start of a line (Linguagem C# é boa is untouched).
  • Line endings are normalized to \n.

Unsupported modes

UnsupportedMode controls headings, thematic breaks and raw HTML, which WhatsApp cannot render. Links and images are never reported as unsupported.

| Mode | Heading / thematic break / HTML | Link | Image | |--------------------|------------------------------------------------------------|------------|------------| | Warn (default) | heading becomes bold, the others are dropped; all recorded | text url | alt: url | | Ignore | as Warn, but raw HTML is kept verbatim | text url | alt: url | | Strip | as Warn | text | alt | | Strict | throws UnsupportedElementError | text url | alt: url |

Errors

  • TypeError when the input is not a string (for example an empty LLM completion that is null) or the mode is unknown.
  • UnsupportedElementError in Strict mode.

Development

pnpm --filter @codebit-programando-solucoes/codebit-md-to-whatsapp test
pnpm --filter @codebit-programando-solucoes/codebit-md-to-whatsapp build

pnpm pack/publish runs prepack (build + obfuscate). Do not publish with --ignore-scripts: the package would ship readable code.