Base64 Encoder & Decoder
Encode text into standard Base64, or decode a Base64 string back into readable text. The conversion runs entirely in your browser and handles UTF-8 correctly, so accented letters, emoji and other multi-byte characters survive the round trip instead of turning into mojibake.
Text to encode
Base64 output
Ready — paste some input or load the sample.
100% Client-Side · Privacy First. This tool runs entirely inside your browser. Nothing you type is uploaded, logged or sent to a server — you can even use it offline.
Overview
Base64 turns arbitrary bytes into a printable ASCII string so it can travel through places that only accept text: JSON bodies, HTTP headers, email bodies, YAML files and URLs. The transformation is not encryption — it has no key and anyone can decode it in a second — but it is the standard way to embed binary safely. The scheme works in blocks of three bytes, which become four characters drawn from the alphabet A-Z, a-z, 0-9, + and /. When the input does not divide evenly into three bytes, one or two = characters pad the output to a multiple of four. The practical consequence is size: Base64 always inflates the payload by roughly a third, which matters when you are embedding an image in a JSON body or passing a certificate through a query parameter. This tool encodes text to Base64 and decodes Base64 back to text, and it reports the encoded length so you can see the overhead before you paste it anywhere.
How to use the base64 encoder & decoder
- 1Paste the text you want to encode into the input panel on the left.
- 2Leave the mode switch on "Encode" if you are starting from plain text, or change it to "Decode" when you already have a Base64 string.
- 3Read the result in the output panel and use the copy button, or download it as a .txt file for longer payloads.
- 4Switch to the URL-safe variant of the tool when the encoded string has to travel inside a query string, a cookie or a JWT segment.
- 5Check the notes panel for the byte and character counts, which tell you whether the payload will still fit into a header.
- 6Paste the value straight into the program that needs it — a shell command, a YAML file or a request body.
- 7Base64 is not encryption: anybody can decode the result, so never put a secret into it.
Cheat sheet
The syntax you will use most, and what each part does.
| Pattern | What it means |
|---|---|
3 bytes become 4 characters |
Base64 expands the payload by about 33 percent, so a 3 KB file becomes roughly 4 KB of text. |
= and == padding |
One equals sign means one leftover byte, two mean two, and the result is always a multiple of four characters. |
A-Z a-z 0-9 + / |
That is the standard alphabet. The URL-safe variant swaps + for - and / for _. |
data:image/png;base64,... |
A Base64 payload can be inlined as a data URI directly in an HTML or CSS file. |
Authorization: Basic dXNlcjpwYXNz |
The value after Basic is the Base64 of username:password, which is encoding, not encryption. |
eyJhbGciOi... |
JWT header and payload segments are Base64URL, so they use - and _ instead of + and /. |
Common mistakes
Base64 is mistaken for encryption.
It is a reversible encoding with no key. Never use it to hide a secret; hash passwords and encrypt data with a real algorithm.
The + and / characters break a URL.
Use the URL-safe variant, which substitutes - and _ and is defined by RFC 4648 section 5.
A decoder rejects the value for missing padding.
Keep the trailing = characters unless you know the consumer strips them. Most languages do not need them, but strict parsers can be picky.
The clipboard truncates a long payload.
Use the download button for anything above a few kilobytes; the file keeps the exact bytes while a copy may wrap or cut them.
Worked examples
A short phrase
Hello
SGVsbG8= — the five characters become eight, because one leftover byte is padded with a single equals sign.
Reading an existing token
SGVsbG8gd29ybGQ=
Decoding returns the original text and a note with the decoded character and byte counts.
Frequently asked questions
Is my text uploaded to a server?
No. The conversion happens with JavaScript inside your own browser tab, which means it keeps working when you disconnect from the network and nothing you paste is ever logged, stored or forwarded to a third party.
Why is the encoded string longer than the original?
Base64 turns every three bytes of input into four characters of output, so the result is about a third bigger than the source. The final group is padded with one or two equals signs so that the length is always a multiple of four.
When should I use the URL-safe variant instead?
Use it whenever the value ends up in a URL, a filename or a header. Standard Base64 contains plus signs and forward slashes, both of which have to be percent-encoded in a query string and both of which can be misread by a shell or a proxy.
Can this encode binary files such as images?
This tool works on text. To embed an image in a stylesheet or an email you normally base64 the file itself, which produces a much larger string than any input box is comfortable with; a command line tool such as base64 or a build step handles that case better.
What is the difference between Base64 and encryption?
Base64 is an encoding, not encryption. It has no key and no secret, so anyone can decode it in one step — it only exists to move binary data through text-only channels such as JSON, mail or a URL.
Why does decoding fail on some strings?
Three things cause it: characters outside the Base64 alphabet, a length that is not a multiple of four once padding is added, and padding that was lost in transit. The notes panel names the offending characters when it finds them.
Does it handle emoji and non-Latin scripts?
Yes. The text is first encoded as UTF-8 bytes and only then converted to Base64, so a character outside the ASCII range takes two, three or four bytes and is represented correctly in the output.
Where is Base64 commonly used?
In HTTP Basic authentication headers, in data URIs for inline images, in JSON Web Tokens, in SMTP attachments and in many configuration files that need to store binary blobs as text.
Does the encoder keep my line breaks?
Yes, a line break is just another byte. A multi-line string encodes to one long line of Base64 with no trace of the original layout, which is why you should decode it before you try to read it.
Can I encode a value that is already Base64?
You can, but the result is Base64 of Base64 and nothing will decode it back to what you meant. Decode first, then encode, whenever you are not certain which direction the value is in.
Why does the tool ask for the mode at all?
Because the two directions are not symmetrical to the eye. A Base64 string is made of a restricted alphabet, so it can look like ordinary text, and a tool that guesses wrong silently gives you nonsense in both directions.