Base64 Encoder & Decoder
Encode and decode Base64, with UTF-8 and URL-safe support
What is Base64 Encoder & Decoder?
A Base64 encoder and decoder that converts in both directions, handles multi-byte UTF-8 characters correctly, and supports the URL-safe variant that swaps + and / for - and _. Encoding and decoding both run in the browser, so your content never leaves the device.
How to use Base64 Encoder & Decoder
- 1Type or paste plain text or a Base64 string into the left pane.
- 2Choose the direction — encode or decode — and the result appears as you type.
- 3Tick the URL-safe option when the output has to go into a URL or a JWT.
- 4If decoding fails, check whether the string was truncated or is missing its = padding.
How do I do this in code?
Use the tool above for one-off work; for anything you repeat, move it into a script or your project.
// Handle non-ASCII text correctly: convert to UTF-8 bytes first
const encode = (text) =>
btoa(String.fromCharCode(...new TextEncoder().encode(text)));
const decode = (b64) =>
new TextDecoder().decode(
Uint8Array.from(atob(b64), (c) => c.charCodeAt(0)),
);Common errors and how to fix them
| Symptom | Cause | Fix |
|---|---|---|
| Non-ASCII text comes back garbled after a round trip | btoa was called on the string directly, without encoding it to UTF-8 bytes first. | Convert to bytes with TextEncoder before encoding, and restore the text with TextDecoder after decoding. |
| Decoding throws an "Invalid character" error | The string is the URL-safe variant (it contains - or _), or its trailing = padding was stripped. | Enable the URL-safe option, or pad the string out to a multiple of four characters. |
Frequently asked questions
Is Base64 a form of encryption?+
No. Base64 is an encoding that represents binary data as ASCII characters, and anyone can decode it — no key is involved at any point. It exists to move data safely through text-only channels, not to keep it secret, so anything sensitive still has to be encrypted separately.
How much bigger does Base64 make my data?+
Roughly a third bigger. Every 3 bytes of input become 4 output characters, so the payload lands around 133% of the original size, plus any line-break overhead. That is exactly why embedding large files as Base64 inside JSON is a bad idea.
What is the difference between URL-safe Base64 and standard Base64?+
Standard Base64 uses + and /, both of which have special meaning inside a URL. The URL-safe variant replaces them with - and _, and usually drops the trailing = padding as well. JWTs use the URL-safe variant, which is why their segments never contain + or /.
Related tools
All toolsFile to Base64
Convert files to Base64 and data URIs — nothing is uploaded
URL Encoder & Decoder
Percent-encode URLs, with separate modes for full URLs and parameter values
HTML Entity Encoder
Escape and unescape HTML entities
Hex to Text Converter
Convert between text and hex with several separator styles
Unicode Escape Converter
Escape and unescape Unicode in three notations
Hash Generator
Compute SHA-1/256/384/512 and MD5 digests