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

rtf-to-html-converter

v1.2.4

Published

Convert text RTF to HTML

Readme

rtf-to-html-converter

A robust JavaScript library to convert RTF (Rich Text Format) strings to clean, readable HTML.

npm version GitHub stars

Installation

npm install rtf-to-html-converter

Usage

const { convertRtfToHtml } = require('rtf-to-html-converter');

const rtf = String.raw`{\rtf1\ansi\ansicpg1252\deff0\nouicompat{\fonttbl{\f0\fnil\fcharset0 Arial;}{\f1\fnil\fcharset0 Arial Black;}}{\colortbl ;\red64\green64\blue64;\red255\green0\blue0;}{\pard\fs30{\b\cf1 Main symptoms:}\sb70\par}{\pard{\b\cf2 Warning in red}\sb70\par}}`;

const html = convertRtfToHtml(rtf);

console.log(html);

Features

  • Converts RTF to HTML with support for:
    • Bold, italic, and underline text
    • Text color (RTF color table and \cfN codes)
    • Unicode characters (e.g. \u237?)
    • Bulleted and numbered lists
    • Paragraph and line break handling
    • Non-breaking spaces
  • Cleans up empty paragraphs and extra whitespace
  • Compatible with both JavaScript and TypeScript projects (includes type definitions)
  • Outputs HTML using <div>, <strong>, <em>, <u>, <span style="color:...">, <ul>, <li>, etc.

Limitations / Known Issues

  • Does not support RTF tables, images, or embedded objects.
  • Only basic text formatting is supported (bold, italic, underline, color, lists, paragraphs).
  • Font face and font size are ignored.
  • Complex nested RTF structures may not be fully converted.
  • Only the color table defined in the RTF is used for color conversion.
  • Output is intended for display, not for round-trip editing back to RTF.

API

convertRtfToHtml(rtf: string): string

Converts an RTF string to HTML.

Parameters

  • rtf (string): The RTF string to convert.

Returns

  • string: The resulting HTML string.

Example Output

<div><strong style="color: rgb(64,64,64);">Main symptoms:</strong></div>
<div>&nbsp;</div>
<div><strong style="color: rgb(255,0,0);">Warning in red</strong></div>

How to run tests

In your VS Code terminal, run:

node test

License

ISC

Maintainers & Contributions

This repository is open source and free to use under the ISC license.
Only the original author can modify or publish new versions to this repository and npm.
If you wish to suggest improvements, please open an issue or a pull request—changes will only be merged at the author's discretion.

Author

Marcelo Saravia

Contact

Support this project

If you find this library useful, you can support its development by buying me a coffee:

Paypal: paypal.me/molinito12