Base64 Encode & Decode
Type text on the left to get Base64 on the right, or paste Base64 on the right to read it. File mode turns an image or document into Base64 and back.
Type in either box. The other one fills in straight away.
File to Base64
Base64 to file
Your text and files are processed on this device and are not uploaded to any server.
How to use it
- Choose Text for writing, or File for images, PDFs and other files.
- In Text mode, type or paste text in the left box, or Base64 in the right box. The other box fills in straight away.
- Tick URL-safe for Base64 used in URLs, file names and JWTs, or 76-character lines for email (MIME). Base64 that is already there is converted to the new format.
- If the Base64 is invalid, the tool shows the line, column and character at fault. Press Show me to select it in the box.
What Base64 is
Base64 writes any data, images and binary files included, using only 64 characters that are safe everywhere: A-Z, a-z, 0-9, + and /. It is used to send binary data through channels that only accept text: email attachments (MIME), data URIs in HTML and CSS, JSON from APIs, JWT tokens and the Authorization: Basic header. The rules are set out in RFC 4648 (October 2006).
How it works
Every 3 bytes (24 bits) are split into 4 groups of 6 bits. Each group has a value from 0 to 63 and is written as one character from the table below. For the text "Hai":
- UTF-8 bytes: H = 72, a = 97, i = 105, or 01001000 01100001 01101001.
- Split into 6 bits: 010010 000110 000101 101001 = 18, 6, 5, 41.
- From the table: 18 = S, 6 = G, 5 = F, 41 = p, so the result is
SGFp.
When the number of bytes is not a multiple of 3, the last group is filled up with zero bits and closed with = (padding): 1 leftover byte becomes 2 characters plus ==, 2 leftover bytes become 3 characters plus =.
Why the size grows by 33%
Every 3 bytes become 4 characters, so the length is 4 × ⌈n ÷ 3⌉. A 30,000-byte image becomes 4 × 10,000 = 40,000 characters, 4/3 the size or about 33% more. Email breaks Base64 into lines of at most 76 characters (RFC 2045, November 1996). 40,000 characters make 527 lines with 526 CRLF line breaks of 2 bytes each, 41,052 bytes in total, about 37% more than the original. For short text the increase is larger: 1 byte becomes 4 characters.
Encoding, not encryption
Base64 uses no key, so it hides nothing. The HTTP header Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== from the example in RFC 7617 reads straight back as Aladdin:open sesame, a user name and password. That header is only safe when it is sent over HTTPS.
The Base64 alphabet (RFC 4648 table 1)
Each cell holds the 6-bit value and then its character.
| 0–15 | 16–31 | 32–47 | 48–63 |
|---|---|---|---|
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 / |
Padding is written =. The URL-safe variant (RFC 4648 section 5) replaces 62 with - and 63 with _.
Questions
Is Base64 a safe way to hide a password?
Why is my Base64 different from another tool's?
[Text.Encoding]::Unicode uses UTF-16, so "Hai" becomes SABhAGkA instead of SGFp. If you paste UTF-16 Base64 like that, the tool recognises it and still shows the text. Other causes: a line break at the end of the text, or the URL-safe or unpadded variants.What is a data URI?
data:image/png;base64,iVBORw0…. You can use it in an image src attribute or in CSS without a separate file. Choose Data URI in File mode. A data URI always uses the standard alphabet without line breaks, whatever the options above say.