Base64 Encode
ED-52Paste text and get its Base64 form. Accents, CJK characters and emoji are encoded as UTF-8, and you can switch to URL-safe output or wrap the lines.
Runs in your browser. Nothing is uploaded.
Text (or Base64 to decode)
Result
How to use it
- Type or paste your text into the input box.
- Tick URL-safe output if the result goes into a URL, a filename or a JWT. Choose a line length if you need wrapped output.
- Click Encode to Base64. The result is shown straight away.
- Copy it or download it as a .txt file. Use Decode to text or Decode to hex to check it the other way.
How the encoding works
Your text is first turned into bytes with UTF-8, so a plain letter is one byte, an accented letter two and an emoji four. Every three bytes then become four characters drawn from A to Z, a to z, 0 to 9, + and /. If the byte count is not a multiple of three, the output ends with one or two = signs as padding. That is why Hello encodes to SGVsbG8= and ends in an equals sign.
URL-safe output and line wrapping
Standard Base64 contains + and /, which have special meaning in URLs. URL-safe output replaces them with - and _ and drops the = padding, which is the form used in JWTs and many filenames. The line length option adds a line break every 64 or 76 characters, the layouts used by PEM files and MIME email. The decode actions ignore those breaks, so wrapped text round trips.
What this is and is not
This encodes text. It does not read a file as raw bytes, so use it for strings, not for images or documents. Base64 is only a way to write bytes using safe characters. It does not hide or protect anything, and anyone can decode it, so never treat it as encryption for passwords or tokens.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
The input has an unpaired surrogate | The text contains half of an emoji or other character outside the basic range, which cannot be turned into UTF-8. | Remove the broken character or replace it with the full one. |
Not valid Base64 | When decoding, the text has characters outside A-Z, a-z, 0-9, +, /, - and _. | Remove stray characters such as quotes or data: prefixes. |
The decoded bytes are not UTF-8 text | The Base64 holds binary data such as an image, not text. | Use Decode to hex to see the bytes. |
Questions people ask
How do I encode a string to Base64?
Paste the string and click Encode to Base64. The text is converted to UTF-8 bytes and those bytes are written with the Base64 alphabet. The result updates as you type, and you can copy it or download it.
What is URL-safe Base64?
It is the same encoding with - and _ in place of + and /, and without the trailing = padding. Use it when the value goes into a URL, a filename or a JWT, where + and / would be misread or need escaping.
Why does Base64 output end with = signs?
Base64 works in groups of three bytes. When the input does not fill the last group, one or two = signs pad the output to a multiple of four characters. URL-safe output leaves the padding off.
Does Base64 encoding make my text secure?
No. Base64 is a reversible way of writing bytes, not encryption. Anyone can decode it in seconds with no key. If you need to protect data, use real encryption and treat Base64 only as a way to carry the encrypted bytes.
Why is the Base64 string longer than my text?
Three bytes become four characters, so the output is about one third larger than the input. Line breaks add a little more. Non-ASCII text grows further because each character takes two to four UTF-8 bytes first.
How do I add line breaks to Base64 output?
Choose 64 characters or 76 characters under Line length before you encode. A line break is inserted after that many characters. 76 matches MIME email and 64 matches PEM files. Decoding ignores the breaks.
About this tool
The text is turned into UTF-8 bytes first, so accents, CJK characters and emoji encode correctly, and the Base64 of those bytes is written out. URL-safe output swaps + and / for - and _ and drops the = padding. The line length option inserts a line break every 64 or 76 characters, the way MIME email and PEM files do; decoding ignores those breaks. This encodes text typed or pasted here. It does not read a binary file as bytes, and Base64 is a way of writing bytes, not encryption, so anyone can decode it. Decode to text needs the bytes to be valid UTF-8; use Decode to hex for anything else.