How to use the Base64 Encode/Decode
- 1Choose Encode or Decode, and Text or File mode.
- 2Type or paste text, or pick a file.
- 3Tick URL-safe if you need base64url (used in JWTs and URLs).
- 4Copy the result or download the decoded file.
What is Base64 encoding?
Base64 is a way to write any data, including images and files, using only 64 safe text characters: A–Z, a–z, 0–9, + and /, with = for padding. This tool encodes text or files to Base64 and decodes Base64 back to text or a downloadable file. It handles Urdu, emoji and other non-English text correctly (UTF-8), supports the URL-safe variant, and previews images from data URIs.
Base64 exists because many systems, like email and JSON, were built for text. Base64 lets binary data travel through them without being damaged.
How does Base64 work?
Base64 is defined in RFC 4648. It works in groups of 3 bytes (24 bits):
- Take 3 bytes of input = 24 bits.
- Split them into four 6-bit groups. Each group is a number from 0 to 63.
- Look up each number in the Base64 alphabet (0 = A, 25 = Z, 26 = a, 52 = 0, 62 = +, 63 = /).
- If the input doesn't divide evenly by 3, pad the output with one or two
=signs.
So every 3 bytes become 4 characters, which is why Base64 output is about 33% larger than the input.
For example, the text "Hi!" is the bytes 72, 105, 33. In binary that's 01001000 01101001 00100001. Regrouped into 6 bits: 010010 000110 100100 100001 = 18, 6, 36, 33 = S, G, k, h. So "Hi!" encodes to SGkh.
What is URL-safe Base64?
Standard Base64 uses + and /, which have special meanings in URLs and file paths. The base64url variant (RFC 4648, section 5) swaps them:
| Standard | URL-safe |
|---|---|
+ | - |
/ | _ |
= padding | Usually removed |
JSON Web Tokens use base64url for all three parts, which is why the JWT Decoder relies on it. This tool's decoder accepts both alphabets, with or without padding.
Worked example
Encode the text Salaam 👋:
- The emoji is 4 bytes in UTF-8, so the whole text is 11 bytes.
- 11 bytes → 4 groups of 3 (the last one partial) → 16 characters including one
=. - Result:
U2FsYWFtIPCfkYs=
Decoding U2FsYWFtIPCfkYs= gives back Salaam 👋. A naive decoder that ignores UTF-8 would show broken characters like ð instead of the emoji, which is a common bug in older tools.
File mode: choose a small PNG and tick "Output as data URI". The result starts with data:image/png;base64,iVBORw0KGgo…. You can paste that directly into an <img src="…"> tag or CSS. Paste a data URI into the decoder and the tool shows the image.
Tips
- Base64 is not encryption. Anyone can decode it in a second. Never use it to "hide" passwords or API keys. For integrity checks, use the Hash Generator.
- Inline only small images. Data URIs skip a network request but are 33% bigger and can't be cached separately. They suit icons under a few kilobytes. For bigger images, compress them with the Image Converter and link them normally.
- For URLs, consider percent-encoding instead. If you just need to put text safely in a query string, the URL Encoder & Decoder is the right tool.
- Decoding binary data as text shows gibberish. Use "Download as binary file" for images, PDFs and ZIPs.
- Inspect decoded JSON with the JSON Formatter.
Limitations
- Line breaks and spaces inside Base64 input are ignored, but any other invalid character causes an error.
- Text output assumes UTF-8. Base64 of text in other encodings (like Windows-1252) may decode with odd characters.
- Very large files (hundreds of megabytes) may be slow or run out of memory because the whole file is held in the browser.
Files you choose are read locally and never uploaded.
Frequently asked questions
Is Base64 encryption?
No. Base64 is an encoding anyone can reverse. Never use it to hide passwords or secrets.
Why is Base64 about a third larger?
It represents every 3 bytes with 4 characters, so output is about 33% larger than the input, plus padding.
What is URL-safe Base64?
It replaces + with - and / with _ and usually drops = padding, so the result can be used in URLs and file names (RFC 4648 section 5).
Why does decoding show strange characters?
The data may be binary (an image or file) rather than text, or the text may not be UTF-8. Use file mode to download binary data.
Last updated: . Written and tested by Abdul Moid Khan, ATechCraft. Read how we build and test tools.