Base64URL Random ID Generator

Base64URL-encoded random bytes

Generating...

About

Base64URL is a URL-safe variant of Base64 encoding. It uses - and _ instead of + and /, and omits padding characters (=). Base64URL IDs are perfect for use in URLs, filenames, and other contexts where special characters might cause issues. They're commonly used in JWT tokens and URL shortening services. Base64URL is defined in RFC 4648 Section 5 and is the recommended encoding for URL-safe contexts.

Use Cases

  • JWT (JSON Web Tokens) encoding
  • URL parameters and path segments
  • URL shortening services
  • Filename-safe identifiers
  • API tokens and keys in URLs
  • Web-safe binary data encoding
  • OAuth and authentication tokens

How to Generate

Library

Native JavaScript (btoa with URL-safe modifications)

NPM Package

N/A - Native implementation

Code Example

// Native implementation
const bytes = new Uint8Array(18);
crypto.getRandomValues(bytes);
const binary = Array.from(bytes)
  .map(b => String.fromCharCode(b))
  .join('');
const base64URL = btoa(binary)
  .replace(/\+/g, '-')
  .replace(/\//g, '_')
  .replace(/=/g, '');