About the Base64 Encode/Decode
Type or paste text to encode it as Base64, or paste a Base64 string to decode it and read the text inside. Developers use it to check API payloads, config files and HTTP headers. It also answers a simpler question: someone has sent you a long block of letters ending in =, and you want to know what the Base64 says.
Results update as you type, and a character count and size sit under both boxes. Text is converted as UTF-8, so accents, Urdu, Arabic, Chinese and emoji come back exactly as they went in. The decoder also reads the URL-safe variant found in tokens and web addresses. A second tab turns a file or photo into a data URI. All of this runs in your browser, and nothing you paste is sent to a server.
How Base64 encoding works
Encoding starts by turning your text into bytes with UTF-8. Plain English letters take one byte each; é takes two, ✓ takes three and most emoji take four. The bytes are then read in groups of three. Each group of 24 bits is cut into four 6-bit pieces, and each piece picks one character from the Base64 alphabet: A–Z for 0 to 25, a–z for 26 to 51, 0–9 for 52 to 61, then + and /.
When the number of bytes isn't a multiple of three, the last group is short and the output is padded with = signs. That's why "Hi" (two bytes) becomes SGk= while "Man", exactly three bytes, becomes TWFu with no padding at all. The encoder writes the standard alphabet with padding, on a single line.
Decoding runs the same steps backwards and is forgiving about the shape of the input: spaces and line breaks are removed, the URL-safe characters - and _ are read as + and /, and missing = padding is restored before the bytes are turned back into text as UTF-8.
Base64 length = 4 × ceil(UTF-8 bytes ÷ 3) leftover bytes after the last full group: 0 → no padding, 1 → "==", 2 → "="
So "Lahore 2026", 11 bytes, needs 4 × ceil(11 ÷ 3) = 16 characters and ends in a single =: TGFob3JlIDIwMjY=.
Assumptions and limits
- A plain Base64 string is always decoded as text. If it holds binary data such as a PDF, a ZIP or a picture, bytes that aren't valid UTF-8 appear as � symbols. For pictures, the Base64 to Image tool shows the image itself.
- A full data URI (data:image/png;base64,...) can be pasted into Decode as it is: the header before the comma is skipped. Text types such as text/plain or application/json are decoded into the right-hand box; for a picture or other binary file the tool reports the file type and size instead, and images get a preview below the boxes.
- Encoding always produces standard Base64 with + and / and = padding. If you need the URL-safe form, replace + with -, / with _ and remove the trailing = signs.
- The output is one continuous line. Email (MIME) Base64 is wrapped at 76 characters; the decoder accepts those line breaks, but the encoder doesn't add them.
- In the Image / File tab, the left box shows the file as a data URI (data:, the file type, then the Base64) and the right-hand box shows the raw Base64 on its own. Editing the left box turns it back into ordinary text, which is then encoded as usual.
- There is no size limit, but a big file becomes a very long string (about a third larger than the file) and can make the text boxes slow, especially on a phone.
Worked examples
Encode text to Base64 for a Basic Auth header
HTTP Basic authentication sends user:password as Base64. Type admin:s3cret in Encode mode and the output is YWRtaW46czNjcmV0: 12 bytes in, 16 characters out, with no padding because 12 divides by three. The request header becomes Authorization: Basic YWRtaW46czNjcmV0. Anyone who sees that header can decode it just as quickly, so send it only over HTTPS.
admin:s3cret = 12 bytes 12 ÷ 3 = 4 groups × 4 = 16 characters result: YWRtaW46czNjcmV0
Decode Base64 to text from an API response
A webhook field such as eyJpZCI6NDJ9 looks random, but switch to Decode, paste it, and the right-hand box shows {"id":42}. Strings that start with eyJ are usually Base64-encoded JSON, because an opening {" followed by a letter always encodes to those three characters.
Accented text and a string with its padding removed
café has 4 letters but 5 bytes in UTF-8 (é takes two), so it encodes to Y2Fmw6k=, 8 characters. Going the other way, the decoder copes with strings whose = signs were stripped, as often happens in URLs: pasting SGVsbG8gV29ybGQ, with no padding, still returns Hello World.
Common text and Base64 values, both ways
Read left to right to encode and right to left to decode. The last column is UTF-8 bytes in and Base64 characters out.
| Text | Base64 | Bytes → characters |
|---|---|---|
| Hi | SGk= | 2 → 4 |
| Man | TWFu | 3 → 4 |
| Hello | SGVsbG8= | 5 → 8 |
| Hello! | SGVsbG8h | 6 → 8 |
| café | Y2Fmw6k= | 5 → 8 |
| ✓ | 4pyT | 3 → 4 |
| user:pass | dXNlcjpwYXNz | 9 → 12 |
| {"id":42} | eyJpZCI6NDJ9 | 9 → 12 |
| Lahore 2026 | TGFob3JlIDIwMjY= | 11 → 16 |
How to use the Base64 Encode/Decode
- Choose Encode or Decode. Stay on the Text Base64 tab and pick Encode to turn text into Base64, or Decode to read a Base64 string.
- Type or paste into the left box. The result appears on the right straight away, with the character count and size of both sides underneath.
- Copy the result. Press Copy above the output. Clear empties both boxes; the Image / File tab turns a file into a data URI instead.
Frequently asked questions
How do I decode a Base64 string to text?
Press Decode and paste the string into the left box; the decoded text shows on the right at once. Spaces, line breaks and missing = signs don't matter. A data: header in front of the string is skipped. If you get an invalid input message, look for characters outside A–Z, a–z, 0–9, +, /, - and _, such as quotation marks copied along with the string.
Is Base64 encoding secure enough to hide a password?
No. Base64 only changes how bytes are written down, and there's no key: anyone can reverse it in a second, as this page shows. It exists to carry data through systems that only accept text. To keep a secret, use real encryption, and store passwords with a dedicated password hash.
Why is the Base64 version longer than my text?
Because every three bytes become four characters, Base64 is about a third bigger than the bytes it holds, plus up to two = signs at the end. Text in Urdu, Arabic, Chinese or with emoji grows even more compared with the number of letters: UTF-8 needs two to four bytes for each of those characters before Base64 adds its third.
What is URL-safe Base64, and can this tool read it?
Yes, the decoder reads it as it is. URL-safe Base64 (base64url in RFC 4648) swaps + for - and / for _, and usually drops the = padding, so the string can sit in a web address or file name. The encoder only writes standard Base64, so swap those two characters yourself when you need the URL-safe form.
Can I convert an image or file to Base64 here?
Yes. Open the Image / File tab, keep Encode selected and choose the file. Its data URI, starting with data: and the file type, appears in the left box, the raw Base64 appears in the right-hand box, and images get a preview underneath. If you need the result as a ready-made <img> tag or raw string with copy buttons, the Image to Base64 tool is built for that.
Why do I see � symbols after decoding?
Because the data wasn't UTF-8 text to begin with. The decoder always turns the bytes back into text as UTF-8. When the original was something else, for example an image, a PDF, compressed data or text saved in an older encoding such as Windows-1252, some bytes have no UTF-8 meaning and are shown as �. The Base64 string itself is usually fine; it just doesn't hold plain text.
This tool runs entirely in your browser. What you enter or upload stays on your device and is never sent to our servers.