Base N Encoder and Decoder
Encode bytes into any base from 2 to 256 using a custom alphabet of your choice. Supply the character set, choose encode or decode, and get a deterministic round-trip with arbitrary radices.
01012345670123456789abcdef0123456789abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~Copy any of these into the alphabet field above, or paste your own. The alphabet must contain at least 2 unique characters and at most 256.
What is Base N?
Base N takes any alphabet between 2 and 256 unique characters and uses it to encode bytes.
Each input string is read as UTF-8, treated as a single big integer, and rewritten as digits
in your chosen base. The first character of the alphabet acts as the leading-zero placeholder,
the same way 1 does in Bitcoin Base58.
The default alphabet shown above is Base62 (digits + letters), but you can paste any unique
character set: hex (0123456789abcdef), an emoji set, custom Crockford with a
checksum row, or even Unicode symbols. Decoding requires the exact same alphabet that was
used to encode.
Tips and gotchas
The alphabet must be free of duplicates β 0123456789 works, but 0123456788 doesn't. Whitespace counts as a character, so leading or trailing
spaces in the alphabet field can change the encoding silently.
There's no padding and no length prefix. The encoded string is the shortest representation that round-trips, plus one alphabet[0] for each leading zero byte in the input. Strings with multi-byte characters (emoji, kanji) work fine β they're encoded as their UTF-8 bytes.
Use the API
Call the same encoder server-side or from another origin. CORS is open, no auth required for the free tier.
curl "https://encode-decode.org/api/v1/basen\ ?action=encode&input=Hello%20World&alphabet=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"