What is Base62 encoding?
Base62 encoding represents binary data using only 62 characters: digits 0-9, uppercase letters A-Z, and lowercase letters a-z. Unlike Base64, it never introduces symbols such as +, /, or =, so the result is always safe to use directly in URLs, filenames, and identifiers without any extra escaping.
Base62 vs Base64
Base64 packs data slightly more densely, but its output can include +, /, and padding = characters that need escaping in URLs and query strings. Base62 trades a little density for an alphanumeric-only output — a common choice for short IDs, slugs, and tokens that need to look clean in a URL.
Use it in your project
npm install base62str
import Base62Str from "base62str";
const base62 = Base62Str.createInstance();
base62.encodeStr("Hello World!"); // "T8dgcjRGkZ3aysdN"
base62.decodeStr("T8dgcjRGkZ3aysdN"); // "Hello World!"