This Base64 encode and decode online tool converts text to Base64 and back. Choose Encode to turn text into Base64, or Decode to turn a Base64 string back into readable text. The result updates as you type.
How to use the Base64 converter
- Choose Encode text to Base64 or Decode Base64 to text.
- Type or paste your input in the top box.
- Read the result in the second box. If a Base64 string is broken, the error tells you why.
- Click Copy result. Click Swap to send the result back as input in the other direction.
Tick URL-safe when encoding if the result will go into a web address or a token.
What Base64 is and why it is used
Base64 is a way to write any data using only 64 safe characters: A-Z, a-z, 0-9, + and /, with = for padding. Some systems, such as email and parts of web pages, were built to carry plain text only. Base64 lets them carry other data, such as images or binary files, without damaging it.
You will see Base64 in:
- Data URLs in HTML and CSS, such as
data:image/png;base64,iVBOR... - Email attachments, which are sent as Base64 text
- JWT tokens used for login on websites, which are three URL-safe Base64 parts joined by dots
- HTTP Basic authentication, where
username:passwordis sent as Base64 (which is why it must only be used over HTTPS)
How Base64 encoding works
Base64 takes 3 bytes (24 bits) at a time and splits them into four 6-bit groups. Each 6-bit number from 0 to 63 maps to one character.
Take the text "Man":
| Step | Value |
|---|---|
| Letters | M, a, n |
| ASCII codes | 77, 97, 110 |
| Bits | 01001101 01100001 01101110 |
| Split into 6-bit groups | 010011 010110 000101 101110 |
| Decimal | 19, 22, 5, 46 |
| Base64 characters | T, W, F, u |
So "Man" becomes TWFu. You can check the bits with the text to binary converter.
| Text | Base64 |
|---|---|
| M | TQ== |
| Ma | TWE= |
| Man | TWFu |
| Hello | SGVsbG8= |
| hello world | aGVsbG8gd29ybGQ= |
The output is always about a third longer than the input: 3 bytes in, 4 characters out.
Common mistake: A common mistake is treating Base64 as a way to protect data. Decoding
SGVsbG8=gives "Hello" in one click, with no key. Use real encryption, or better, do not store secrets in the browser at all.
Text in Hindi, Telugu and other languages
Base64 works on bytes, not letters. This tool first turns your text into UTF-8 bytes, so every language works. "नमस्ते" is 6 characters on screen but 18 bytes in UTF-8, and it encodes to 4KSo4KSu4KS44KWN4KSk4KWH. Some older tools only handle English letters and fail on such text.
Base64 in code
| Language | Encode | Decode |
|---|---|---|
| JavaScript (browser) | btoa("Hello") |
atob("SGVsbG8=") |
| Python | base64.b64encode(b"Hello") |
base64.b64decode("SGVsbG8=") |
| Java | Base64.getEncoder().encodeToString("Hello".getBytes()) |
new String(Base64.getDecoder().decode("SGVsbG8=")) |
In JavaScript, btoa accepts only characters with codes up to 255, so convert other text to UTF-8 bytes first, as this tool does.
Pro tip: Need to put text inside a URL rather than a token? Percent-encoding is usually the right choice there. Use the URL encoder and decoder.
