Base64 Encoder
Convert text to Base64 and back, with correct UTF-8 handling and an optional URL-safe alphabet.
What Base64 actually does
Base64 is a binary-to-text encoding: it takes raw bytes and rewrites them using only 64 printable ASCII characters — A–Z, a–z, 0–9, + and /, with = used as padding. Every 3 input bytes become 4 output characters, which is why the encoded result is always about 33% larger than the original.
The point is not compression or secrecy. It exists because plenty of protocols and file formats only tolerate text: email attachments (MIME), JSON Web Tokens, data: URLs in CSS and HTML, basic auth headers, and Kubernetes secrets all carry binary payloads this way. If a system mangles non-ASCII bytes, Base64 is the usual fix.
Use the URL-safe alphabet for URLs and filenames
Standard Base64 output can contain + and /, which have meaning inside URLs and file paths. The URL-safe variant (RFC 4648 §5) swaps them for - and _ and usually drops the padding. This tool applies that substitution when you tick URL-safe alphabet, which is what JWT segments and most APIs expect.
Why UTF-8 matters here
Browsers' built-in btoa() only accepts Latin-1 characters, so a naive implementation silently corrupts anything with an accent, an emoji, or a Chinese character. This encoder converts the string to UTF-8 bytes first, then encodes those bytes — so héllo and 你好 round-trip exactly. Decoding does the reverse and reports an error rather than printing mojibake when the input is not valid Base64.
Remember: Base64 is not encryption
Anyone can decode it in one line of code. Treating Base64 as protection for API keys or passwords is a recurring security bug. If you need confidentiality, encrypt first (AES-GCM, libsodium) and Base64-encode the ciphertext for transport — never the secret itself.
Frequently asked questions
Is my data uploaded to a server?
btoa/atob and TextEncoder APIs. Nothing is sent over the network, which is why this tool is safe for internal tokens and config values.Why is my Base64 string 33% bigger?
Can I decode a Base64 image or PDF?
data:image/png;base64, prefix) and switch to Decode. Binary results are not rendered as text, so for files you are usually better off using the browser console or a small script.