Skip to content

Base64 and Base-N Encoder and Decoder

Direction
Result
—
Bytes
—
Encoded size vs bytes
—

Paste text, choose Encode or Decode, and pick a format. Text is turned into UTF-8 bytes first, then written in that alphabet: foobar is Zm9vYmFy in Base64, MZXW6YTBOI====== in Base32 and 666F6F626172 in hex. Decoding reverses it and shows the bytes as text, or as hex when they are not text.

About this tool

Developers meet Base64 inside JSON payloads, JWT segments, data URIs and email attachments, and meet its cousins elsewhere: Base32 in two-factor secrets, Base58 in Bitcoin addresses, Ascii85 inside PDF streams and plain hex in hashes and packet dumps. This page converts between UTF-8 text and all six alphabets in either direction, so you can check what a header or token holds without opening a terminal. The result shows how many bytes were involved and how much larger the encoded form is; Base64 adds about 33 percent, hex doubles the size. One limit: a decoded image, PDF or other binary file is shown as hex characters, not saved as a file. Everything runs in your browser.

How to use it

  1. Paste the input

    Type or paste text, or open a .txt file holding an encoded string.

  2. Pick a direction

    Encode turns plain text into the alphabet; Decode reads an encoded string back to text.

  3. Choose the format

    Base64, URL-safe Base64, Base32, Base58, Ascii85 or hex. Spaces and line breaks in encoded input are ignored.

  4. Copy the result

    Use the Copy button on the result box; the steps show the byte count behind it.

Examples

foobar to Base64

Input
foobar
Direction
Encode
Format
Base64

Result Result: Zm9vYmFy
Bytes: 6
Encoded size vs bytes: 133.3%

  1. Text to UTF-8 bytes: 6 bytes (666F6F626172)
  2. Base64 encoding: 6 bytes become 8 characters

Six bytes split into two 3-byte groups, and each group becomes four characters, so no padding is needed.

foobar to Base32

Input
foobar
Direction
Encode
Format
Base32

Result Result: MZXW6YTBOI======
Bytes: 6
Encoded size vs bytes: 266.7%

  1. Text to UTF-8 bytes: 6 bytes (666F6F626172)
  2. Base32 encoding: 6 bytes become 16 characters

Base32 works in 5-byte blocks of eight characters, so the last partial block is filled out with six equals signs.

Decode Zm9vYmE=

Input
Zm9vYmE=
Direction
Decode
Format
Base64

Result Result: fooba
Bytes: 5
Encoded size vs bytes: 160%

  1. Base64 decoding: 8 characters become 5 bytes
  2. Bytes read as UTF-8 text: 5 characters

One equals sign at the end means the last group held two bytes, so eight characters decode to five letters.

How it is calculated

Base64 (RFC 4648 §4): every 3 bytes of UTF-8 input become 4 characters from A–Z, a–z, 0–9, + and /, padded with =

Base64URL
RFC 4648 §5: – and _ replace + and /, and padding is dropped
Base32
RFC 4648 §6: 5 bytes become 8 characters from A–Z and 2–7
Base58
the bytes read as one big number in base 58, without 0, O, I and l; each leading zero byte becomes 1
Ascii85
4 bytes become 5 characters from ! to u; an all-zero group becomes z

Text is first converted to UTF-8, so an accented letter or emoji takes two to four bytes before encoding. Base64, Base32 and hex regroup the bits into 6, 5 or 4-bit pieces. Base58 treats the whole input as a single integer and divides it by 58 repeatedly, which is why it has no padding and grows slowly on long input. When decoding, the tool strips whitespace, accepts Base64 with or without padding, accepts the URL-safe alphabet in the Base64 setting too, and drops the start and end markers some Ascii85 tools wrap around their output.

Sources

Use from code or an AI agent Free API · MCP

The same calculation is a free JSON API. No key needed. The answer is in result.stats.primary.

curl -X POST https://api.tools-directory.workers.dev/v1/tools/base64-and-base-n-encoder-and-decoder \
  -H 'Content-Type: application/json' \
  -d '{"inputs":{"text":"foobar","direction":"encode","format":"base64"}}'

When not to use it

  • Base64 is not encryption; anyone can decode it, so never use it to hide passwords.
  • To turn a Base64 string back into a downloadable image or PDF, use a decoder that writes a file.
  • Base58Check addresses carry a checksum that this page does not verify.

Common mistakes

  • Decoding URL-safe Base64 with the Base32 setting, or Base32 with the Base64 setting, gives an error or noise.
  • Copying a data URI with its data:image/png;base64, prefix still attached.
  • Expecting Base58 and Base64 output of the same text to have the same length.

Frequently asked questions

How do I decode a Base64 string to text?

Paste the string, choose Decode and keep the format on Base64. Whitespace and line breaks are ignored, and missing = padding is tolerated. The bytes are read as UTF-8, so SGVsbG8= becomes Hello. If the bytes are not valid text, they are shown as hex instead.

What is URL safe Base64?

It is the Base64 variant from RFC 4648 section 5. The characters + and / are replaced with – and _ so the string can sit in a URL or filename without escaping, and the trailing = padding is usually left off. JWT tokens use it. The text ??> is Pz8+ in normal Base64 and Pz8- in the URL-safe form.

How do I convert Base64 to hex?

Decode the Base64 string first. When the bytes are not text, the result already shows them as hex. When they are text, copy that text, choose Encode and the Hex format. Each byte becomes two hex digits, so Zm9vYmFy (foobar) is 666F6F626172.

How do I base64 encode in Python?

Use the standard library: import base64, then base64.b64encode('foobar'.encode('utf-8')).decode('ascii') returns Zm9vYmFy. For the URL-safe form use base64.urlsafeb64encode, and b64decode or urlsafeb64decode to go back. The output here matches Python for any UTF-8 text, which helps check a script.

What is the base64 decode command on Linux?

GNU coreutils ships it: echo 'Zm9vYmFy' | base64 –decode prints foobar, and echo -n foobar | base64 encodes it. Use -n with echo, or the trailing newline is encoded too and the result ends in Cg== instead. On macOS the decode flag is -D or –decode.

What is a Base32 decoder used for?

Base32 uses only capital letters and the digits 2 to 7, so it survives case-insensitive systems and is easy to read aloud. Two-factor authenticator secrets are Base32. Decoding MZXW6=== gives foo; the padding fills the last 8-character block.

How does a Base58 decoder differ from Base64?

Base58 drops 0, O, I, l, + and / so the result can be typed without confusion, which is why Bitcoin addresses and IPFS hashes use it. It treats the input as one large number, so it has no padding. Hello World! encodes to 2NEpo7TZRRrLZSi2U.

Cite this tool

Using this tool in an assignment, article or report? Copy a citation, or a link for your website.

APA

Tools Directory Editorial Team. (2026, December 3). Base64 and Base-N Encoder and Decoder. Tools Directory. Retrieved December 4, 2026, from https://directory.milunir.com/developer-tools/encoders-decoders/base64-and-base-n-encoder-and-decoder/

MLA

Tools Directory Editorial Team. “Base64 and Base-N Encoder and Decoder.” Tools Directory, 3 Dec. 2026, https://directory.milunir.com/developer-tools/encoders-decoders/base64-and-base-n-encoder-and-decoder/. Accessed 4 Dec. 2026.

Chicago

Tools Directory Editorial Team. “Base64 and Base-N Encoder and Decoder.” Tools Directory. Last modified December 3, 2026. Accessed December 4, 2026. https://directory.milunir.com/developer-tools/encoders-decoders/base64-and-base-n-encoder-and-decoder/.

Link<a href="https://directory.milunir.com/developer-tools/encoders-decoders/base64-and-base-n-encoder-and-decoder/">Base64 and Base-N Encoder and Decoder – Tools Directory</a>