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

rtf-to-text

v0.1.1

Published

Strip RTF to clean plaintext. Zero dependencies, handles Unicode escapes, control groups, smart quotes, and plain-text passthrough.

Readme

rtf-to-text

npm CI zero dependencies types: included license: Apache-2.0

Strip RTF down to clean plaintext. One function, zero dependencies, ESM + CJS + types.

RTF is a format you receive, rarely one you want. A user pastes from Word, an export drops a .rtf, a clipboard hands you {\rtf1\ansi...} instead of the sentence inside it. The npm options for getting the text back out are mostly heavyweight document parsers or packages that haven't been touched in years. This is the small, sharp tool: give it a string, get the words.

npm install rtf-to-text

Use it

import { stripRtf } from 'rtf-to-text';

stripRtf('{\\rtf1\\ansi Hello \\b world\\b0}');
// → "Hello world"

stripRtf('Already plain text.');
// → "Already plain text."   (non-RTF passes through untouched)

CommonJS works too:

const { stripRtf } = require('rtf-to-text');

What it handles

  • Passthrough — input that isn't RTF (doesn't start with {\rtf) is returned unchanged, so you can run it over a mixed pile of .rtf and .txt without sniffing each one first.
  • Control groupsfonttbl, colortbl, stylesheet, info, pict, and friends are skipped wholesale, not leaked as noise — including any \*-marked ignorable destination (e.g. \*\generator, \*\themedata) that Word and friends sprinkle through real documents.
  • Unicode escapes\uN? decoded properly, including negative (16-bit-wrapped) values, and the trailing ANSI replacement char is consumed.
  • Structure\par / \line → newlines, \tab → tab; runs of blank lines are collapsed and the result is trimmed.
  • Escaped literals & punctuation\{, \}, \\, plus smart quotes, bullet, en/em dashes mapped to their real characters.
  • Formatting\b, \i, \fs24, and every other presentational control word is dropped silently.

What it is not

A faithful RTF parser or a fonts-and-colors document model. It throws formatting away on purpose — the goal is the text a human would read, suitable for search indexing, analysis, ingestion pipelines, diffing, or just showing the user what they actually pasted. If you need to preserve styling, reach for a full document library instead.

API

function stripRtf(input: string): string

Pure and synchronous. No I/O, no configuration, no state. The same input always returns the same output.

Why this exists

Extracted from a production text-analysis pipeline (a CEFR teaching tool) where teachers paste passages from Word and the RTF wrapper has to come off before anything else can happen. It earned its keep there over thousands of real documents; this is that one piece, tested and standalone.

License

Apache-2.0 © Jim Vinson · jimvinson.com