Base64 Encoder & Decoder
Encode text to Base64 or decode Base64 strings back to text instantly.
- Free
- No account
- Runs in your browser
- Nothing uploaded
Runs entirely in your browser — your input is never uploaded, logged, or stored.Privacy policy
What is Base64 Encoder & Decoder?
Base64 is a binary-to-text encoding scheme that represents arbitrary data using 64 printable ASCII characters: A-Z, a-z, 0-9, +, and /. It's the standard way to embed binary data in text-based formats — email attachments (MIME), data URIs in HTML/CSS, JWT tokens, HTTP Basic Auth headers, and API credentials.
The encoding works by taking every 3 bytes (24 bits) of input and splitting them into 4 groups of 6 bits. Each 6-bit group maps to one of the 64 characters in the alphabet. This means Base64 expands data by about 33% — 3 input bytes become 4 output characters. That expansion is the trade-off for being able to safely transport any binary data through text-only channels.
Two variants matter in practice: • Standard Base64 uses + and / as the 62nd and 63rd characters. This is what you want for email, JWT payloads, and most APIs. • URL-safe Base64 replaces + with - and / with _. This is required in URLs, filenames, and anywhere + or / would be misinterpreted as path separators.
Both variants add padding (=) at the end to make the output length a multiple of 4. The padding is not data — it's structural, and your decoder should accept input with or without it.
Encoding follows RFC 4648 (The Base16, Base32, and Base64 Data Encodings):
1. Read input as UTF-8 bytes. 2. Process bytes in 3-byte chunks. For each chunk: • Combine 24 bits into a single integer. • Split into 4 groups of 6 bits each. • Map each 6-bit value to its Base64 character (A-Z=0-25, a-z=26-51, 0-9=52-61, +=62, /=63). 3. If the final chunk has fewer than 3 bytes: • 1 remaining byte → 2 Base64 characters + 2 padding (=) • 2 remaining bytes → 3 Base64 characters + 1 padding (=)
Decoding reverses this process. The implementation uses the browser's built-in TextEncoder and TextDecoder for UTF-8 handling, ensuring correct behavior with multi-byte characters (emojis, CJK, accented characters).
URL-safe variant: replace + with - and / with _ before encoding, reverse after decoding. The padding (=) works the same way in both variants.
| Standard Base64 | URL-safe Base64 | |
|---|---|---|
| Characters 62-63 | + and / | - and _ |
| Safe in URLs | No (+ and / are special) | Yes |
| Safe in filenames | No | Yes |
| JWT payloads | No (use URL-safe) | Yes |
| Email (MIME) | Yes | No (use standard) |
| HTTP Basic Auth | Yes | No |
Worked examples
- Encode "Hello, World!": SGVsbG8sIFdvcmxkIQ==
- Encode "Hello, World!" (URL-safe): SGVsbG8sIFdvcmxkIQ== (same — no + or / in this output)
- Encode "🎉" (emoji): 8J+Rig== (4 bytes UTF-8 → 4 Base64 chars + padding)
- Decode "SGVsbG8sIFdvcmxkIQ==": Hello, World!
- Decode "SGVsbG8sIFdvcmxkIQ": Hello, World! (padding optional)
- Decode "8J+Rig": 🎉 (URL-safe input works without padding)
How to use Base64 Encoder & Decoder
- Paste or type your text in the input box.
- Choose Encode (text → Base64) or Decode (Base64 → text).
- Select Standard or URL-safe variant if needed.
- Copy the result. Nothing is stored — closing the tab is all the cleanup there is.
Common errors
- Decode error: "Invalid character" — the input contains characters outside the Base64 alphabet. Check for spaces, newlines, or stray punctuation.
- Decode error: "Invalid padding" — the input length is not a multiple of 4. Some systems omit trailing = signs; this decoder accepts both.
- Encoded output contains + or / — this is standard Base64. If you need URL-safe output, switch the variant selector.
- Emoji or non-Latin text encodes to longer output — this is expected. Multi-byte UTF-8 characters (like 🎉 = 4 bytes) expand to more Base64 characters than single-byte ASCII.
FAQ
Is Base64 encryption or encoding?
Encoding, not encryption. Base64 is reversible by design — it's a way to represent binary data as text, not a way to hide it. Anyone with the Base64 string can decode it instantly. If you need to hide data, use actual encryption (AES, RSA) first, then Base64-encode the ciphertext if you need to transport it as text.
Why does my Base64 output look different from other tools?
Most likely a difference in padding or URL-safe vs. standard variant. Some tools omit trailing = padding; this tool includes it by default. If your output contains + or / and you need URL-safe output (- and _), switch the variant selector.
Does this handle UTF-8 text correctly?
Yes — the encoder reads input as UTF-8, so multi-byte characters (emojis, CJK, accented characters) encode correctly. A single emoji like 🎉 is 4 bytes in UTF-8 and becomes 4 Base64 characters, not 1.
Can I decode Base64 with or without padding?
Yes — this decoder accepts both padded (SGVsbG8=) and unpadded (SGVsbG8) input. The padding characters (=) are structural and can be safely omitted in most systems, though some strict decoders require them.
What's the difference between Base64 and Base64URL?
Base64URL (RFC 4648 §5) replaces + with - and / with _ to make the output safe for URLs and filenames. Standard Base64 (RFC 4648 §4) uses + and / which can be misinterpreted in URL contexts. This tool supports both variants.
Why is my encoded string 33% longer than the input?
That's expected — Base64 encodes every 3 bytes as 4 characters, so output is always ~33% larger than the input. This expansion is the trade-off for being able to safely transport any binary data through text-only channels.
Related tools
Prefer AllUtil on Google
One click adds AllUtil to your Google preferences. You'll see our tools highlighted with a Preferred badge in Search and AI answers.