Base64 is a way to write any binary data (text, an image, an archive) using only "safe" characters: Latin letters A–Z, a–z, digits 0–9 and the signs + and /. This online base64_encode and base64_decode tool encodes a string to Base64 and decodes it back right in your browser; the text is not sent anywhere.
How it works
The data is split into groups of 3 bytes (24 bits), each group into 4 parts of 6 bits, and each part is replaced with a character from a 64-symbol alphabet. If bytes are missing at the end, the result is padded with =.
Why the result is a third larger
3 bytes become 4 characters, so encoded data is about 33% larger than the original (plus possible line breaks). Base64 is convenient for transport, not for saving space.
Examples
| Input | Base64 |
|---|---|
| a | YQ== |
| ab | YWI= |
| Hello, World! | SGVsbG8sIFdvcmxkIQ== |
| Привет (UTF-8) | 0J/RgNC40LLQtdGC |
| user:pass | dXNlcjpwYXNz |
URL-safe variant (base64url)
The characters + and / have special meaning in URLs, so there is a base64url variant: + becomes -, / becomes _, and the trailing = is usually dropped. For example, the bytes FB FF BF are +/+/ in standard Base64 and -_-_ in base64url.
Where it is used
- data: URIs — images and fonts directly in HTML and CSS:
data:image/png;base64,iVBORw0... - Email attachments — the MIME standard sends files in emails as Base64.
- JWT — the token header and payload are base64url-encoded and can be decoded and read.
- HTTP Basic authentication — the header
Authorization: Basic dXNlcjpwYXNzcarries "user:pass" in Base64. - APIs and JSON — sending files and binary fields where only text is allowed.
Good to know
- Base64 is NOT encryption. Anyone can decode the string in a second. Do not store passwords or secrets this way: Basic auth and JWT are safe only over HTTPS and with a signature.
- Text is converted to UTF-8 bytes before encoding, so Cyrillic takes twice as many characters as Latin.
- Spaces and line breaks inside Base64 are usually ignored when decoding, while other stray characters cause an error.
- In PHP use
base64_encode()/base64_decode(); in JavaScriptbtoa()/atob()(Latin-1 only) orBufferin Node.js.
How to use the page
- Type text into the source field — Base64 appears in the result field.
- Or paste Base64 into the result field — the source text is decoded automatically.
- The copy button puts the result on the clipboard.