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

r85

v1.1.3

Published

Binary and text encoding with radix-85 representation

Readme

npm node license

r85

This is a binary and text encoding tool that uses radix-85 representation.

It's like base64, only that it uses 85 symbols rather than 64, which produces smaller results. This is also different from base64 because it provides encryption.

It can be used from the command line or programatically as a node module in any Node.js® script.

TL;DR

Although I strong recommend reading the whole document, if you're in a rush to start using this package, or just need a quick sample code to start, jump straight to the Examples section. Though, even is the case, you might also like to take a look at the Using as a CLI tool section.

It's lightning fast

Check out the time to encode and decode 1GB of data in an AMD Ryzen 9 3900X:

| Format | Encoding | Decoding | |:-------|---------:|---------:| | Binary | 1038ms | 403ms | | String | 971ms | 853ms |

Using as a CLI tool

If you want to use r85 directly from the command line, install it globally with npm install -g r85 and run r85 --help for usage.

Usage: r85 [OPTIONS]... [FILE]
Encode or decode FILE or stdin to stdout by default.
Options:
  -d, --decode       decodes FILE (default if file has .r85 extension)
  -e, --encode       encodes FILE (default if file doesn't have .r85 extension)
  -o, --out=FILE     writes to FILE
  -k, --key=KEY      a key to encrypt/decrypt the data
  -K, --key          same as -k, but read key from stdin
                     and cannot be used together with [FILE]
  -f, --force        overwrites output FILE (--out or -o) if it exists
  -h, --help         print this help

With no [FILE], reads stdin.
With no [FILE] and with --key (or -K), key is first line from stdin.
With no --out=FILE (or -o FILE), writes to stdout.

Using as a node module

Obviously r85 can be also be just required in any node module to be used programatically.

Usually these would be the steps to encode/decode data:

  1. require r85
  2. create an instance
  3. call one of the four methods: encode, encodeToString, decode, decodeToString

Encoding content

The encode method accepts Array, TypedArray, Buffer and String as argument. It always return a Buffer with the encoded content.

Decoding content

Similarly, the decode method accepts Array, TypedArray, Buffer and String as argument. It also always return a Buffer with the decoded content.

Encoding and decoding strings

The special methods encodeToString and decodeToString also accept Array, TypedArray, Buffer and String as argument. However they return a String rather than a Buffer. That might be convenient in some situation.

Examples

Encode/decode binary data without encryption

const fs = require('fs');
const R85 = require('r85');

const r85 = new R85();

const buffer = fs.readFileSync('file.bin');
const encodedBuffer = r85.encode(buffer);
const decodedBuffer = r85.decode(decodedBuffer);

fs.writeFileSync('file.bin.r85', encodedBuffer);

// file.bin.copy has the same content as file.bin
fs.writeFileSync('file.bin.copy', decodedBuffer);
const R85 = require('r85');

const r85 = new R85();

const euroSymbolUTF8Bytes = [0xE2, 0x82, 0xAC];
const encodedBuffer = r85.encode(euroSymbolUTF8Bytes);
const encodedArray = Array.from(euroSymbolEncodedBuffer);
const encodedString = String.fromCharCode.apply(null, encodedArray);

// logs [ 51, 101, 67, 51 ]
console.log(encodedArray);

// logs 3eC3
console.log(encodedString);

Encode/decode text without encryption

const R85 = require('r85');

const r85 = new R85();

const euroSymbol = '€'; // this is 2-byte in UCS2 \u20AC
const encodedString = r85.encodeToString(euroSymbol);
const decodedString = r85.decodeToString(encodedString);

// logs 3eC3
console.log(encodedString);

// logs €
console.log(decodedString);

Encode/decode data with encryption

In order to encode data with encryption, or decode previously encryted encoded data, provide a key as argument to the constructor.

const R85 = require('r85');

const r85 = new R85('s3cret');

const euroSymbol = '€'; // this is 2-byte in UCS2 \u20AC
const encodedString = r85.encodeToString(euroSymbol);
const decodedString = r85.decodeToString(encodedString);

// logs XncX
console.log(encodedString);

// logs €
console.log(decodedString);

Maintainer

| willchb-avatar | |:----------------------------:| | Willian Balmant |