Encode a short text
Hello, dev247!
SGVsbG8sIGRldjI0NyE=
The input is 14 bytes. 14 is not a multiple of 3, so the last group is padded with one =.
Convert text and files to Base64, or decode Base64 back to readable text, images and files. Live as you type, UTF-8 safe, and nothing leaves your browser.
- and _), MIME line breaks every 76 characters, or a data URL for files.Hello, dev247!
SGVsbG8sIGRldjI0NyE=
The input is 14 bytes. 14 is not a multiple of 3, so the last group is padded with one =.
café ☕
Y2Fmw6kg4piV
é takes 2 bytes and ☕ takes 3 bytes in UTF-8, so these 6 characters become 9 bytes and exactly 12 Base64 characters, with no padding.
ZGV2MjQ3Lm5ldA==
dev247.net
Two = signs mean the last group held only one byte of real data.
admin:s3cret
YWRtaW46czNjcmV0
Send it as Authorization: Basic YWRtaW46czNjcmV0. Anyone who sees this header can decode the password, so only use Basic auth over HTTPS.
Base64 is a way to write any binary data, such as an image, a file or text in any language, using only 64 safe characters: A–Z, a–z, 0–9, + and /. Every 3 bytes of input become 4 characters of output, so the encoded text is about 33% larger than the original. In return, it can travel safely through systems that only handle plain text, such as email, JSON, HTML, XML and HTTP headers.
Base64 is defined in RFC 4648. It is an encoding, not encryption: anyone can decode it, and no key is involved.
Base64 reads the input 3 bytes (24 bits) at a time and splits those 24 bits into four groups of 6 bits. Each 6-bit group is a number from 0 to 63, and that number picks one character from the Base64 alphabet. Here is the word Man, step by step:
| Step | M | a | n |
|---|---|---|---|
| ASCII value | 77 | 97 | 110 |
| 8-bit binary | 01001101 | 01100001 | 01101110 |
The 24 bits 010011010110000101101110 are regrouped into four 6-bit numbers:
| 6-bit group | 010011 | 010110 | 000101 | 101110 |
|---|---|---|---|---|
| Decimal | 19 | 22 | 5 | 46 |
| Base64 character | T | W | F | u |
So Man becomes TWFu. Decoding simply runs the same steps backwards.
Each character stands for one 6-bit value. The standard alphabet from RFC 4648 is:
| Value | Char | Value | Char | Value | Char | Value | Char |
|---|---|---|---|---|---|---|---|
| 0 | A | 16 | Q | 32 | g | 48 | w |
| 1 | B | 17 | R | 33 | h | 49 | x |
| 2 | C | 18 | S | 34 | i | 50 | y |
| 3 | D | 19 | T | 35 | j | 51 | z |
| 4 | E | 20 | U | 36 | k | 52 | 0 |
| 5 | F | 21 | V | 37 | l | 53 | 1 |
| 6 | G | 22 | W | 38 | m | 54 | 2 |
| 7 | H | 23 | X | 39 | n | 55 | 3 |
| 8 | I | 24 | Y | 40 | o | 56 | 4 |
| 9 | J | 25 | Z | 41 | p | 57 | 5 |
| 10 | K | 26 | a | 42 | q | 58 | 6 |
| 11 | L | 27 | b | 43 | r | 59 | 7 |
| 12 | M | 28 | c | 44 | s | 60 | 8 |
| 13 | N | 29 | d | 45 | t | 61 | 9 |
| 14 | O | 30 | e | 46 | u | 62 | + |
| 15 | P | 31 | f | 47 | v | 63 | / |
The = sign is not part of the alphabet. It is only used for padding.
Base64 works in groups of 3 bytes. When the input length is not a multiple of 3, the last group is short, and = signs fill the output up to a multiple of 4 characters:
==. Example: M → TQ===. Example: Ma → TWE=Man → TWFuSome formats drop the padding because the length already tells the decoder how many bytes are missing. JWTs do this with Base64URL. This tool accepts input with or without padding.
The encoded length is 4 × ceil(n / 3) characters for n bytes, which is about 33% more. A 300 KB image becomes about 400 KB of Base64 text. MIME email adds a line break every 76 characters, which costs roughly another 2–3%. That overhead is why Base64 is great for small files and short values, but a poor choice for embedding large images in HTML or CSS.
data:image/png;base64,iVBORw0KGgo…user:password is Base64-encoded in the Authorization header.-----BEGIN CERTIFICATE-----) are Base64 between the header lines.data: are Base64-encoded.| Variant | Characters 62 and 63 | Padding | Typical use |
|---|---|---|---|
| Standard (RFC 4648 §4) | + / | Yes | Most APIs, data URLs, PEM |
| URL-safe (RFC 4648 §5) | - _ | Usually no | JWTs, URLs, file names |
| MIME (RFC 2045) | + / | Yes | Email, lines of 76 characters |
The decoder on this page accepts both + / and - _, ignores spaces and line breaks, and strips a leading data:…;base64, prefix automatically.
Base64 is not encryption. It hides nothing. Never use it to "protect" passwords, API keys or personal data. If you need secrecy, encrypt the data first (for example with AES-GCM), then Base64-encode the ciphertext if it has to travel as text.
btoa() and atob() only handle Latin-1 characters, so convert text to UTF-8 bytes first:
// Text → Base64 (UTF-8 safe)const bytes = new TextEncoder().encode('café ☕');const b64 = btoa(String.fromCharCode(...bytes)); // "Y2Fmw6kg4piV" // Base64 → textconst back = new TextDecoder().decode( Uint8Array.from(atob(b64), (c) => c.charCodeAt(0)));const b64 = Buffer.from('café ☕', 'utf8').toString('base64');const text = Buffer.from(b64, 'base64').toString('utf8'); // URL-safe variant without paddingconst url = Buffer.from('café ☕').toString('base64url');$b64 = base64_encode('café ☕'); // "Y2Fmw6kg4piV" // Pass true for strict mode: returns false on invalid characters$text = base64_decode($b64, true);import base64 b64 = base64.b64encode('café ☕'.encode('utf-8')).decode('ascii')text = base64.b64decode(b64).decode('utf-8') # URL-safe varianturl = base64.urlsafe_b64encode(b'\xfb\xff').decode() # "-_8="echo -n 'hello' | base64 # aGVsbG8=echo 'aGVsbG8=' | base64 --decode # hello # GNU base64 wraps lines at 76 characters; -w 0 turns that offbase64 -w 0 image.png > image.b64InvalidCharacterError: The string to be decoded is not correctly encoded (atob in the browser)
The input contains characters outside the standard alphabet. The usual causes are URL-safe characters (- and _), a data: prefix, or stray quotes. Paste it into this tool: it accepts both alphabets, strips data URL prefixes and points to the exact position of any invalid character.
binascii.Error: Incorrect padding (Python)
The = padding was removed, which is common with JWTs and URLs. Add it back before decoding: s += "=" * (-len(s) % 4), or use base64.urlsafe_b64decode for URL-safe input.
btoa: The string to be encoded contains characters outside of the Latin1 range
btoa() only accepts characters with codes up to 255. Encode the text as UTF-8 bytes first with TextEncoder, as shown in the JavaScript example above.
The decoded text looks garbled, like café instead of café
The bytes are correct, but they were read with the wrong character set (Latin-1 instead of UTF-8). Decode the bytes as UTF-8. This tool always uses UTF-8.
The output is random symbols, or the tool says "Binary data"
The Base64 holds a file, not text: an image, a PDF, a ZIP or compressed data. Use Download to save it. Images also show a preview. If it should be text, it may have been compressed or encrypted before it was encoded.
No. Base64 is a reversible encoding with no key, so anyone can decode it in a second. Use it to move binary data through text-only channels, never to hide secrets.
The = signs are padding. Base64 encodes 3 bytes at a time, and when the input length is not a multiple of 3, one or two = fill the last 4-character group. One = means the last group had 2 bytes; == means it had 1 byte.
About 33% larger: every 3 bytes become 4 characters. 3 MB of data becomes roughly 4 MB of Base64, plus about 2–3% more if MIME line breaks are added.
Base64URL replaces + with - and / with _ so the result is safe in URLs and file names, and it usually drops the = padding. JWTs use Base64URL. This decoder accepts both.
Yes. Choose Encode, drop the image onto the left box and turn on "Data URL for files" to get a string you can use directly in <img src="…"> or CSS. Decoding a Base64 image shows a preview and lets you download it.
No. Encoding and decoding run entirely in your browser with JavaScript. Your text and files never leave your device, which you can confirm in the Network tab of your browser's developer tools.
Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.
Tip: press Ctrl D to bookmark dev247.