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

b58uuid

v1.0.0

Published

High-performance Base58-encoded UUID library for JavaScript/TypeScript with zero dependencies

Readme

B58UUID for JavaScript/TypeScript

npm version CI License: MIT TypeScript

High-performance Base58-encoded UUID library for JavaScript and TypeScript with zero runtime dependencies.

39% shorter than standard UUIDs • URL-safeUnambiguousFast

Features

  • 39% more compact: 22 characters instead of 36
  • URL-safe: No special characters that need escaping
  • Unambiguous: Uses Bitcoin's Base58 alphabet (excludes 0, O, I, l)
  • Fast: Optimized encoding/decoding with BigInt
  • Zero dependencies: No external runtime dependencies
  • TypeScript support: Full type definitions included
  • Cross-platform: Works in Node.js and browsers (with bundler)
  • 100% test coverage: Comprehensive test suite
  • Error handling: Custom error types for better debugging

Quick Comparison

Standard UUID:  550e8400-e29b-41d4-a716-446655440000  (36 characters)
B58UUID:        BWBeN28Vb7cMEx7Ym8AUzs                (22 characters)
                                                       ↑ 39% shorter!

Installation

npm install b58uuid

Usage

JavaScript

const { generate, encode, decode } = require('b58uuid');

// Generate a new UUID
const b58 = generate();
console.log(b58); // Output: 3FfGK34vwMvVFDedyb2nkf

// Encode existing UUID
const encoded = encode('550e8400-e29b-41d4-a716-446655440000');
console.log(encoded); // Output: BWBeN28Vb7cMEx7Ym8AUzs

// Decode back to UUID
const uuid = decode('BWBeN28Vb7cMEx7Ym8AUzs');
console.log(uuid); // Output: 550e8400-e29b-41d4-a716-446655440000

TypeScript

import { generate, encode, decode } from 'b58uuid';

// Generate a new UUID
const b58 = generate();
console.log(b58); // Output: 3FfGK34vwMvVFDedyb2nkf

// Encode existing UUID
const encoded = encode('550e8400-e29b-41d4-a716-446655440000');
console.log(encoded); // Output: BWBeN28Vb7cMEx7Ym8AUzs

// Decode back to UUID
const uuid = decode('BWBeN28Vb7cMEx7Ym8AUzs');
console.log(uuid); // Output: 550e8400-e29b-41d4-a716-446655440000

API

Functions

generate(): string

Generate a new random UUID v4 and return its Base58 encoding.

import { generate } from 'b58uuid';

const id = generate();
console.log(id); // "3FfGK34vwMvVFDedyb2nkf"

encode(uuidStr: string): string

Encode a standard UUID string to Base58 format.

import { encode } from 'b58uuid';

const b58 = encode('550e8400-e29b-41d4-a716-446655440000');
console.log(b58); // "BWBeN28Vb7cMEx7Ym8AUzs"

Parameters:

  • uuidStr: UUID string (with or without hyphens)

Returns: Base58-encoded string (exactly 22 characters)

Throws: InvalidUUIDError if the UUID format is invalid

decode(b58Str: string): string

Decode a Base58 string back to standard UUID format.

import { decode } from 'b58uuid';

const uuid = decode('BWBeN28Vb7cMEx7Ym8AUzs');
console.log(uuid); // "550e8400-e29b-41d4-a716-446655440000"

Parameters:

  • b58Str: Base58-encoded string (must be exactly 22 characters)

Returns: UUID string in canonical format (with hyphens)

Throws: InvalidB58Error if the Base58 string is invalid

Error Types

B58UUIDError

Base error class for all b58uuid errors.

class B58UUIDError extends Error {
  constructor(message: string, originalError?: Error);
}

InvalidUUIDError

Thrown when an invalid UUID format is provided to encode().

class InvalidUUIDError extends B58UUIDError {
  constructor(uuidStr: string, originalError?: Error);
}

InvalidB58Error

Thrown when an invalid Base58 string is provided to decode().

class InvalidB58Error extends B58UUIDError {
  constructor(b58Str: string, originalError?: Error);
}

Error Handling Example

import { encode, decode, InvalidUUIDError, InvalidB58Error } from 'b58uuid';

try {
  encode('invalid-uuid');
} catch (error) {
  if (error instanceof InvalidUUIDError) {
    console.error('Invalid UUID:', error.message);
  }
}

try {
  decode('0000000000000000000000'); // Contains '0' which is not in Base58
} catch (error) {
  if (error instanceof InvalidB58Error) {
    console.error('Invalid B58:', error.message);
  }
}

Testing

# Run tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm run test:coverage

Performance

B58UUID is optimized for performance:

  • Encoding: ~100,000+ ops/sec
  • Decoding: ~80,000+ ops/sec
  • Generation: ~50,000+ ops/sec

Benchmarks run on Node.js 20.x on a modern CPU.

Browser Support

B58UUID works in modern browsers when bundled with tools like:

  • Webpack
  • Rollup
  • Vite
  • esbuild

Note: Requires a bundler that can polyfill Node.js crypto module for browser environments.

Contributing

Contributions are welcome! Please read our Contributing Guide for details.

Publishing

See PUBLISHING.md for instructions on how to publish this package to npm.

Note: If you have 2FA enabled on npm, see 2FA_SETUP.md for automated publishing setup.

Changelog

See CHANGELOG.md for release history.

License

MIT License - see LICENSE file for details.

Related Projects

B58UUID is available in multiple languages:

Links

Support


Made with ❤️ by the B58UUID community