Skip to content

Base64 Encode and Decode

Encode text to Base64 and decode Base64 strings back to readable text, with full UTF-8 support.

Base64 Encode and Decode tool

Loading...

Example

Input: Hello, World!

Result: SGVsbG8sIFdvcmxkIQ==

The 13 UTF-8 bytes are split into 6-bit groups and mapped to the Base64 alphabet. The == padding appears because 13 is not a multiple of 3.

Base64 Encoding Examples

TextUTF-8 bytesBase64
A1QQ==
Hi2SGk=
abc3YWJj
Hello5SGVsbG8=
user:pass9dXNlcjpwYXNz
café5Y2Fmw6k=
€34oKs

Produced by this tool. Padding depends on the byte count, not the letter count.

  1. To encode, type or paste your plain text into the Text panel.
  2. The Base64 string appears instantly in the Base64 panel as you type.
  3. To decode, paste a Base64 string (standard or URL-safe, with or without padding) into the Base64 panel.
  4. Read the decoded text in the Text panel, or check the error message if the string is not valid Base64.
  5. Use the swap button to move the Base64 result into the Text panel if you want to encode it again.
  6. Click the copy button above either panel to copy its contents to your clipboard.

How Base64 Encoding Works

Base64 turns any data into text made from 64 safe characters: A to Z, a to z, 0 to 9, + and /. This tool encodes text to Base64 and decodes Base64 back to text, so Hello becomes SGVsbG8= and back again. The encoder works on bytes, not letters. Your text is first turned into UTF-8 bytes. Every 3 bytes (24 bits) are then split into four 6-bit groups, and each group picks one of the 64 characters. When the input is not a multiple of 3 bytes, one or two = signs pad the end. That is why the output is always about a third larger than the input: 3 bytes in, 4 characters out.

You meet Base64 in email attachments, data URLs, JSON Web Tokens and HTTP Basic Auth headers, where the value is username:password in Base64. It is not encryption. Anyone can decode it in a second, so never treat a Base64 string as hidden. For real protection, use Text Encryption and Decryption.

The decoder is forgiving. It ignores spaces and line breaks, accepts the URL-safe alphabet that uses - and _ instead of + and /, and adds missing padding. The encoder always writes standard Base64 with padding. This tool handles text only. To turn a picture into a data URL, use the Image to Base64 Converter.

Sources

Frequently Asked Questions

No. Base64 is an encoding with no key, so anyone can reverse it. It exists to carry data safely through systems that only accept text, such as email or JSON. If a Base64 string holds a password or API key, treat it exactly as if the secret were written in plain text.
Base64 works in blocks of 3 bytes. If the last block has only 2 bytes, one = is added, and if it has only 1 byte, two are added. For example, Hi (2 bytes) encodes to SGk= and A (1 byte) to QQ==. Some systems leave the padding out, and this decoder accepts either form.
This tool decodes to text, so the decoded bytes must be valid UTF-8. A Base64 string that holds an image, a PDF or other binary data decodes to bytes that are not text, and the tool reports an error instead of showing garbage. Characters outside the Base64 alphabet also cause the error, apart from spaces and line breaks, which are ignored.
Standard Base64 uses + and /, which have special meaning in URLs and file names. The URL-safe variant, used in JSON Web Tokens, swaps them for - and _ and usually drops the = padding. This tool encodes to the standard form and decodes both.
Every 3 bytes become 4 characters, so the output is about 33 percent larger, plus up to two padding characters. Text with accents or emoji grows more than you might expect, because those characters take 2 to 4 bytes each in UTF-8 before encoding. The euro sign, for example, is 3 bytes and becomes 4oKs.

Related Tools

URL Encode and Decode

Encode special characters for URLs or decode percent-encoded strings back to readable text.

Developer Tools

HTML Entity Encode and Decode

Convert special characters to HTML entities and decode HTML entities back to readable text.

Developer Tools

Hash Generator

Generate MD5, SHA-1, SHA-256, SHA-384, and SHA-512 hashes from text or files right in your browser.

Developer Tools

JWT Decoder

Decode JSON Web Tokens to inspect header, payload, and signature without needing the secret key.

Developer Tools

URL Parser

Break down URLs into protocol, host, port, path, query parameters, and hash components.

Developer Tools

Text Encryption and Decryption

Encrypt and decrypt text using AES-256 encryption entirely in your browser. No data sent to servers.

Security and Encryption