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

@iiojib/base32

v1.0.3

Published

Base32 encoding and decoding

Readme

Base32

Base 32 encoding and decoding for Deno, Bun, Node.js and browsers.

  • No dependencies
  • Custom alphabets
  • Supports aliases (e.g. Crockford's Base32)
  • Configurable case sensitivity
  • Optional paddings

Installation

To install the package, use one of the following methods:

NPM

npm install @iiojib/base32

Deno

deno add jsr:@iiojib/base32

Bun

bun add @iiojib/base32

Usage

Encoding and Decoding

You can use the Base32 and Base32Hex:

import { Base32, Base32Hex } from "@iiojib/base32";

const utfEncoder = new TextEncoder();
const utfDecoder = new TextDecoder();

const input = utfEncoder.encode("hello!");

// Standard base 32 encoding
const encoded = Base32.encode(input);
console.log(encoded); // Output: NBSWY3DPEE

const encodedWithPadding = Base32.encode(input, true);
console.log(encodedWithPadding); // Output: NBSWY3DPEE======

const decoded = Base32.decode(encoded);
console.log(utfDecoder.decode(decoded)); // Output: hello!

// Base 32 encoding with extended hex alphabet
const encodedHex = Base32Hex.encode(input);
console.log(encodedHex); // Output: D1IMOR3F44

const decodedHex = Base32Hex.decode(encodedHex);
console.log(utfDecoder.decode(decodedHex)); // Output: hello!

Note

The Base32 and Base32Hex encodings are case insensitive.

Custom Encoding

You can create a custom base 32 encoding with a given alphabet and options:

import { makeBase32Encoding } from "@iiojib/base32";

const zBase32Alphabet = "YBNDRFG8EJKMCPQXOT1UWISZA345H769";
const zBase32 = makeBase32Encoding(zBase32Alphabet);

const utfEncoder = new TextEncoder();
const utfDecoder = new TextDecoder();

const encoded = zBase32.encode(utfEncoder.encode("hello!"));
console.log(encoded); // Output: PB1SA5DXRR

const decoded = zBase32.decode(encoded);
console.log(utfDecoder.decode(decoded)); // Output: hello!

Options

You can customize the encoding with the following options:

  • caseSensitive: If true, the encoding will be case-sensitive, default is false.
  • aliasTable: Optional alias table for character substitution.
  • padding: Padding character, default is =.
const crockfordAlphabet = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
const weirdBase32 = makeBase32Encoding(crockfordAlphabet, {
  caseSensitive: true,
  aliasTable: { "O": "0", "I": "1", "L": "1" },
  padding: "*",
});