How to decode and encode Base64
- Choose Encode to Base64 to turn text into Base64, or Decode from Base64 for the other way. The result updates as you type.
- When encoding, tick URL-safe for tokens and URLs, Remove = padding if the receiver wants none, or Wrap at 76 for email (MIME) style lines.
- Copy the result or download it. Use as input moves it back into the box so you can chain an encode and a decode to check a round trip.
Examples: Hello encodes to SGVsbG8=, and decoding SGVsbG8= gives back Hello.
What Base64 is
Base64 represents binary data using 64 printable characters: A-Z, a-z, 0-9, + and /. Every 3 bytes become 4 characters, so the output is about 33% larger than the input, and a trailing = or == pads the last group. It exists so that data can travel through systems built for text: email attachments, data URLs, JSON fields, HTTP headers such as Basic authentication.
Base64 is not encryption. Anyone can decode it, so never use it to hide a password. It is an encoding, like writing a number in hexadecimal. The specification is RFC 4648.
Padding, in three examples
The padding comes from how many bytes are left in the final group of three:
| Text | Bytes | Base64 |
|---|---|---|
| a | 1 | YQ== |
| ab | 2 | YWI= |
| abc | 3 | YWJj |
| Hello, World! | 13 | SGVsbG8sIFdvcmxkIQ== |
One leftover byte gives ==, two give =, none give no padding. Many systems drop the padding (JWT, URLs) because the length already tells you how much is missing. This decoder accepts text with or without it: SGVsbG8 decodes to Hello.
URL-safe Base64 and Unicode
The standard alphabet uses + and /, which have a meaning in URLs. The URL-safe variant replaces them with - and _. The same bytes Hi?>> give SGk/Pj4= in the standard alphabet and SGk_Pj4 in the URL-safe one without padding. The decoder understands both, so you can paste either.
Text is converted to UTF-8 bytes first, so Café ☕ encodes to Q2Fmw6kg4piV and decodes back unchanged. Older online tools that use JavaScript's btoa directly fail on any character outside Latin-1 or mangle it; this one does not. If you decode Base64 that was made from a file (an image, a PDF), the bytes are not text and the tool says so.
When Base64 text will not decode
The decoder tells you why. Decoding SGVsbG8* gives: Not valid Base64: the character "*" at position 8 is not in the Base64 alphabet.
- A character outside the alphabet: a stray quote, comma or the prefix
data:image/png;base64,pasted in. Remove it. - Wrong length: the text was cut. A valid Base64 length leaves 0, 2 or 3 characters in the last group, never 1.
- Padding in the middle: two Base64 strings joined together; decode them one at a time.
- The result looks like garbage: the data is binary (a file, a compressed or encrypted value), or it is text in another encoding such as UTF-16.
Whitespace and line breaks are ignored when decoding. To read the three parts of a JSON Web Token use the JWT decoder; for percent-encoding in URLs use URL encode and decode.
Related tools
- URL encoder and decoder – percent-encoding for URLs and query strings
- JWT decoder – a JWT is three Base64URL parts
- Hash generator – one-way fingerprints, not reversible like Base64
- JSON formatter
Base64 encode and decode FAQ
How do I decode Base64 online?
Choose Decode from Base64 and paste the text. The decoded text appears at once; whitespace, URL-safe characters and missing padding are all accepted.
How do I encode text to Base64?
Keep Encode to Base64 selected and type or paste your text. The text is converted to UTF-8 first, so accents and emoji work.
Is Base64 encryption?
No. It is a reversible encoding that anyone can decode. Do not use it to protect passwords or secrets.
What does the = at the end mean?
It is padding that fills the last group of 4 characters. One = means 2 bytes were left in the last group, two = means 1 byte. Some systems omit it.
What is URL-safe Base64?
A variant that uses - and _ instead of + and /, so the text can sit in a URL or file name without escaping. JWTs use it.
Why does my decoded text look like random symbols?
The data is probably binary (a file or compressed data) or text in a different encoding. The tool shows a note when the bytes are not valid UTF-8.
Is my text sent to a server?
No. Everything happens in your browser and nothing is uploaded or stored.