Base64 Encoder / Decoder

Encode text to Base64 or decode Base64 back to text. Supports URL-safe encoding. Free, instant, and private — all processing happens in your browser.

Embed this tool

Advertisement

Ad

What Is Base64?

Base64 is one of the most common binary-to-text encoding schemes on the web. It takes arbitrary bytes — text, images, PDFs, or any other data — and represents them as a string made from 64 safe ASCII characters: uppercase letters, lowercase letters, digits, and the symbols + and /. Because the output contains only printable characters, it can travel through systems that were designed for plain text, such as JSON payloads, email bodies, XML documents, and URL query strings.

The encoding works by splitting every group of 3 input bytes into four 6-bit chunks. Each 6-bit chunk maps to one of the 64 characters in the Base64 alphabet. When the input length is not divisible by 3, one or two padding = characters are appended so the output length is always a multiple of 4. This predictable structure makes Base64 easy to encode, decode, and validate in almost every programming language.

How to Use This Tool

Select whether you want to encode plain text into Base64 or decode Base64 back into readable text. Paste your input into the left panel and the result appears instantly on the right. Toggle the URL-safe option to convert + to -, / to _, and remove padding — perfect for JWT tokens, URL parameters, and filenames. Click the copy button to grab the output, or use Swap direction to reverse the operation.

Common Use Cases

  • Data URIs: embed small images, fonts, or icons directly in HTML or CSS without extra HTTP requests.
  • JSON Web Tokens (JWT): JWT headers and payloads are Base64url encoded.
  • URL parameters: pass binary identifiers or serialized data safely in query strings.
  • Email and MIME: email attachments are commonly encoded with Base64 so they survive text-based mail transfer.
  • Configuration files: store certificates, keys, or small binaries as plain text in YAML, JSON, or environment variables.

Worked Example

Let us encode the word Hello. First, convert each character to its UTF-8 byte value: 72 101 108 108 111. The encoder groups these bytes into 6-bit chunks and maps each chunk to a Base64 character, producing the output SGVsbG8=. The trailing = is padding because 5 bytes do not divide evenly into groups of 3. Decoding SGVsbG8= returns the original Hello exactly.

Tips and Best Practices

  • Expect roughly a 33% size increase when converting binary data to Base64.
  • Use URL-safe Base64 whenever the result will appear in a URL, JWT, or filename.
  • Do not use Base64 to hide sensitive data — it is encoding, not encryption.
  • Validate that decoded strings have valid padding and only use the allowed alphabet.
  • For large files, prefer direct binary transfer or object storage instead of Base64.

Frequently Asked Questions

Base64 is a binary-to-text encoding scheme defined in RFC 4648. It represents binary data using 64 printable ASCII characters: A–Z, a–z, 0–9, +, and /. Every 3 bytes of input are split into four 6-bit groups, each mapped to one character. Use Base64 when you need to transmit binary data through text-only channels, embed small images directly in HTML or CSS as data URIs, store binary tokens in JSON, or include binary payloads in email MIME messages.

Related Tools