Developer & Tech
Base64 Encoder & Decoder
Enter your details
Runs in your browser
How to use it
Using the base64 encoder & decoder
- 01
Paste your content
Any text in any language; encoding handles the full Unicode range.
- 02
Pick the direction
Encode turns text into Base64; decode expects valid Base64 and returns text.
- 03
Copy the result
Encoded output includes standard “=” padding accepted everywhere.
Good to know
What Base64 is actually for
Base64 converts arbitrary bytes into printable ASCII safe for channels designed around text: email attachments, JSON string fields, data URIs, HTTP basic auth headers. It costs about 33% extra size; it is an encoding, never encryption.
The Unicode trap
Naïve btoa() usage throws on characters above U+007F because it treats each char as a byte. Correct handling encodes UTF-8 bytes first; which is exactly what this tool does, so 世界 and emoji survive intact both directions.
Padding rules worth knowing
- Length divisible by 3 → no padding
- One byte left over → “==”
- Two bytes left over → “=”
- Stray “=” anywhere else means corruption
How it's calculated
The math behind this calculator
Base64: groups of 3 bytes → 4 characters; padding = pads the final partial groupText is first converted to UTF-8 bytes, then each group of three bytes (24 bits) is split into four six-bit values mapped onto the standard A–Z, a–z, 0–9, +, / alphabet. A leftover group of one or two bytes is padded with one or two “=” signs.
Decoding reverses the mapping after validating the alphabet, length multiple of four and correct padding placement, so corrupt input fails loudly instead of silently producing garbage bytes.
Assumptions & limitations
- Standard alphabet with + and / (not the URL-safe -_ variant).
- Whitespace inside Base64 is ignored when decoding.
- Decoded bytes are interpreted strictly as UTF-8.
Worked example
“Hello, 世界!” contains multibyte UTF-8 characters; its encoding is the classic SGVsbG8sIOS4lueVjCE=; proof the pipeline is Unicode-safe.
FAQ
Frequently asked questions
- Is Base64 encryption?
- No; it is a reversible encoding with no key. Anyone can decode it instantly; use it for transport compatibility, never secrecy.
- Why does encoded output end with = sometimes?
- Padding completes the final incomplete 3-byte group so total output length is always a multiple of four characters.
- Can I decode URL-safe Base64 (- and _)?
- Not directly here; replace dashes with + and underscores with / first, then add missing padding.
- Why did decoding fail?
- Most often a stray character outside the alphabet, wrong padding, or a length that is not a multiple of four. The error names the specific problem.
Keep exploring