Base64 Encoder / Decoder
Encode text or files to Base64, or decode Base64 strings back to plain text.
Input type
Mode
What is Base64?
Base64 is an encoding scheme that converts binary data into a string of ASCII characters using 64 printable characters (A-Z, a-z, 0-9, +, /). It is commonly used to embed binary data in text formats like JSON, XML, HTML, and email.
Standard Base64
Uses + and / characters. Standard for most use cases like data URIs and email attachments.
URL-safe Base64
Replaces + with - and / with _ to avoid encoding conflicts in URLs and filenames.
How to encode or decode Base64
- Choose Encode or Decode.
- Type or paste your text. The result updates as you type.
- Tick URL-safe if the result goes into a URL, a filename or a JWT.
- To turn a file (an image, a font, a PDF) into Base64, switch to the File tab and pick it.
How Base64 works, in one example
Base64 takes the input three bytes at a time, which is 24 bits, and splits them into four groups of six bits. Each six-bit number (0–63) maps to one character of the alphabet A–Z a–z 0–9 + /. Take the word Man:
Text M a n
ASCII 77 97 110
Bits 01001101 01100001 01101110
Regroup 010011 010110 000101 101110
Index 19 22 5 46
Base64 T W F u → "TWFu"That's the whole trick. It also explains the 33% size increase (4 output characters for every 3 input bytes) and the trailing =padding when the input doesn't divide evenly by three.
Standard vs URL-safe Base64
Two characters of the standard alphabet cause trouble in URLs: + is read as a space in query strings, and / is a path separator. URL-safe Base64 (also called base64url, RFC 4648 §5) swaps them for - and _ and usually drops the =padding. It's what JSON Web Tokens use, which is why you can't always paste a JWT segment into a plain Base64 decoder. Our JWT Decoder handles that for you.
Where you'll run into Base64
- Data URIs:
data:image/png;base64,iVBORw0…embeds a small image directly in HTML or CSS. - Email attachments: MIME encodes binary attachments as Base64 so they survive mail servers built for text.
- HTTP Basic Auth: the header
Authorization: Basic dXNlcjpwYXNzis justuser:passin Base64. Anyone who sees it can read the password, which is why it must only travel over HTTPS. - JWTs and API payloads: binary values such as hashes, signatures and keys are carried as Base64 inside JSON.
- Kubernetes secrets: values in a Secret manifest are Base64-encoded. It's still worth repeating that this is not encryption.
Base64 isn't always the right tool, though. Inlining large images as data URIs, for example, often makes pages slower rather than faster. We cover the good and bad uses in When to use Base64 encoding (and when not to).
Command-line equivalents
- macOS / Linux:
echo -n 'hello' | base64andecho 'aGVsbG8=' | base64 --decode - Windows PowerShell:
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes('hello')) - JavaScript:
btoa()andatob(), but only for ASCII text. UseTextEncoderfirst for anything else.
Note the -n on echo: without it, a newline is encoded too and you get aGVsbG8K instead of aGVsbG8=. That one-character difference has confused a lot of people.
Frequently asked questions
Is Base64 a form of encryption?+
No. Base64 is an encoding, not encryption: there is no key, and anyone can decode it instantly. It's used to make data safe to transport through text-only channels, not to hide it. Never rely on it to protect passwords or personal data.
Why is Base64 output bigger than the input?+
Base64 represents every 3 bytes of input with 4 characters, so the output is about 33% larger, plus up to two padding characters. A 3 MB image becomes roughly 4 MB of Base64 text.
What does the = at the end mean?+
It's padding. Base64 works on groups of 3 bytes; when the input length isn't a multiple of 3, one or two = signs fill the last group. URL-safe Base64 usually drops the padding, and this decoder adds it back automatically.
Why do I get "Invalid Base64 string" when decoding?+
Either the input contains characters outside the Base64 alphabet (often a stray space, line break or quote), or it decodes to binary data rather than text, such as an image or a compressed file. The text decoder expects the result to be valid UTF-8.
Does it handle emoji and accented characters?+
Yes. Text is converted to UTF-8 bytes before encoding and back after decoding, so "café ☕" survives the round trip. Plain btoa() in JavaScript would throw an error on those characters.
Further reading
Last updated October 16, 2026