Base64 Encoder & Decoder
Encode and decode Base64 and Base64URL, with UTF-8 handled correctly in both directions.
Output — base64.txt
About this tool
Convert text to Base64 and back, including the URL-safe variant used by JWTs and query-string tokens. Non-ASCII text is handled properly - accents, Cyrillic and emoji survive the round trip, which the naive one-line implementations do not manage. Everything happens in your browser, so nothing you paste leaves the machine.
Why the naive version corrupts text
The one-liner everyone reaches for is btoa(text), and it throws an exception the moment the text contains a character above U+00FF - which includes every emoji and most non-English writing. btoa works on bytes, not characters, and it assumes each character is one byte.
The correct sequence is: encode the string to UTF-8 bytes, then Base64 those bytes. This tool does exactly that with TextEncoder on the way in and TextDecoder on the way out, which is why the Polish sample in the encode preset round-trips instead of turning into question marks.
Standard versus URL-safe
Standard Base64 uses + and / as its last two characters and = for padding. All three are reserved in URLs, so a token pasted into a query string gets mangled. The URL-safe variant from RFC 4648 swaps + for - and / for _, and drops the padding entirely. That is what every JWT segment uses.
Decoding here accepts either alphabet and re-adds missing padding, so you do not need to know which variant produced the string you were handed.
Frequently asked questions
Is Base64 encryption?
No, and this matters. Base64 is a reversible encoding with no key, designed to move binary data through text-only channels. Anyone can decode it in one command. A password or API key "protected" by Base64 is stored in plain text with an extra step.
Why does the output end in one or two equals signs?
Base64 works on three-byte groups and produces four characters per group. When the input length is not a multiple of three, = pads the last group out so decoders know how many bytes were real. The URL-safe variant drops the padding because the length implies it.
Should I inline images as Base64 data URIs?
Rarely. Base64 makes the data about 33% larger and, embedded in CSS or HTML, it becomes render-blocking bytes that cannot be cached separately or lazy-loaded. It is defensible for a tiny icon that would otherwise cost a request. For anything above a couple of kilobytes a normal file with a cache header wins.
Can I decode a Base64 image or PDF here?
You can decode it, but the output box only shows text. Binary data appears as replacement characters, and the tool says so when it detects them. For binary, decode with a command line tool that writes to a file: base64 -d input.txt > output.png.