Base64 Encode & Decode
Turn text or a file into Base64, or decode Base64 back to readable text. Unicode is handled correctly, the URL-safe alphabet is one click away, and decoding accepts either alphabet with or without padding.
0 characters · 0 words · 0 lines
0 characters · 0 words · 0 lines
Runs entirely in this browser tab. Your text is never uploaded or stored.
The Base64 alphabet
Index → character from RFC 4648. The highlighted last two differ in the URL-safe variant: 62 is + or -, 63 is / or _.
- 0A
- 1B
- 2C
- 3D
- 4E
- 5F
- 6G
- 7H
- 8I
- 9J
- 10K
- 11L
- 12M
- 13N
- 14O
- 15P
- 16Q
- 17R
- 18S
- 19T
- 20U
- 21V
- 22W
- 23X
- 24Y
- 25Z
- 26a
- 27b
- 28c
- 29d
- 30e
- 31f
- 32g
- 33h
- 34i
- 35j
- 36k
- 37l
- 38m
- 39n
- 40o
- 41p
- 42q
- 43r
- 44s
- 45t
- 46u
- 47v
- 48w
- 49x
- 50y
- 51z
- 520
- 531
- 542
- 553
- 564
- 575
- 586
- 597
- 608
- 619
- 62+ -
- 63/ _
How long the output gets
Every 3 input bytes become 4 characters; a final group of 1 or 2 bytes is padded with = in standard Base64 and left unpadded in the URL-safe form.
| Input | Bytes | Standard | URL-safe | Length |
|---|---|---|---|---|
U | 1 | VQ== | VQ | 4 |
Ul | 2 | VWw= | VWw | 4 |
Ult | 3 | VWx0 | VWx0 | 4 |
UltK | 4 | VWx0Sw== | VWx0Sw | 8 |
UltKi | 5 | VWx0S2k= | VWx0S2k | 8 |
UltKit | 6 | VWx0S2l0 | VWx0S2l0 | 8 |
What Base64 does
Base64, defined in RFC 4648, writes arbitrary bytes using 64 printable ASCII characters: A–Z, a–z, 0–9, + and /. Every group of three bytes (24 bits) is split into four 6-bit numbers, and each number picks one character from the alphabet. When the input length is not a multiple of three, the final group is padded with one or two = signs. The result is always about 33% larger than the input: 4 characters for every 3 bytes.
It exists because many channels were built for text. Email (MIME), data: URLs in HTML and CSS, JSON fields that carry images or certificates, and HTTP Basic authentication headers all use Base64 to move binary data safely. It is not encryption and hides nothing; decoding needs no key.
Unicode and the URL-safe variant
Base64 encodes bytes, not letters, so text must first be turned into bytes. This tool always uses UTF-8, the encoding the web runs on: é becomes two bytes and an emoji four. The browser's built-in btoa function alone throws an error on any character above U+00FF, which is why naive encoders fail on accents and emoji; here the text goes through TextEncoder first, and decoding reverses it with TextDecoder. If decoded bytes are not valid UTF-8 (an image, a zip file), the tool shows them as hexadecimal instead of garbled text.
Standard Base64 uses + and /, which have meanings in URLs and file names. The URL-safe alphabet from section 5 of RFC 4648 replaces them with - and _, and padding is usually dropped. JSON Web Tokens use exactly this form. The decoder accepts both alphabets and missing padding, so you can paste either.
Encoding files and images
Choose a file and the tool reads it locally with FileReader and returns its Base64, or a complete data: URL with the file's MIME type ready to paste into an img tag or a CSS background. Inline images save an HTTP request but grow by a third and cannot be cached separately, so they suit small icons rather than photos. For images with a preview and ready-made HTML and CSS snippets, use Image to Base64.
Frequently asked questions
- Why is the Base64 output longer than my input?
- Each 3 bytes become 4 characters, so output is about 4/3 the size of the input, plus up to two padding characters. Non-ASCII text is longer still, because UTF-8 uses two to four bytes per character.
- What are the = signs at the end?
- Padding. They make the output length a multiple of four when the input length is not a multiple of three. One = means the last group had two bytes, two = mean it had one byte.
- Why does decoding fail with an invalid character error?
- The input contains something outside the alphabet, such as a space inside a word, a quote, or a % from URL encoding. Line breaks and missing padding are tolerated; other characters are not.
- Is it safe to Base64-encode a password?
- Base64 offers no protection. HTTP Basic authentication sends user:password in Base64, which is why it must only be used over HTTPS. Use real encryption or hashing to protect secrets.
- What is the difference between Base64 and Base64url?
- Only two characters and the padding: Base64url uses - and _ instead of + and / and usually omits =, so the result can sit in URLs and file names without escaping.