Step-by-step guide: What Is Base64 Encoding and When Should You Use It?
How to use the Base64 Encoder and Decoder
- For text, type or paste into the Text box and select Encode text; or paste Base64 into the right-hand box and select Decode Base64.
- Tick URL-safe when the result will go into a URL, file name or JSON Web Token. It uses
-and_instead of+and/and drops the=padding. - For files, switch to File, choose a file and copy the Base64 output — optionally as a data URI that can be used directly in HTML or CSS.
- To turn Base64 back into a file, paste it into the decode box, give the file a name with the right extension, and download it.
Example: UTF-8 text and a data URI
Encoding Grüße 👋 produces R3LDvMOfZSDwn5GL. Each accented letter becomes two bytes in UTF-8 and the emoji becomes four, which is why the Base64 is longer than the text.
A small PNG icon encoded as a data URI begins data:image/png;base64,iVBORw0KGgo… and can be placed straight into an <img src="…"> attribute or a CSS url().
What Base64 is for
Base64 represents binary data using only 64 safe text characters: A–Z, a–z, 0–9, plus + and /. It exists because many systems — email, JSON, XML, URLs, HTTP headers — were designed for text and can corrupt raw binary data. Common uses include email attachments (MIME), embedding small images in HTML or CSS, HTTP Basic authentication headers and the parts of JSON Web Tokens.
Base64 is an encoding, not encryption. Anyone can decode it, so it provides no security.
How encoding works
Every 3 bytes of input (24 bits) are split into four 6-bit groups, and each group is mapped to one of the 64 characters. If the input length is not a multiple of three, = padding characters fill the final group. As a result, Base64 output is about 33% larger than the original data.
Text is first converted to bytes with UTF-8, the standard encoding for the web. When decoding, the tool checks that the result is valid UTF-8; if it is not, the data is probably a binary file, and the tool suggests decoding it as a file instead.
Limitations to keep in mind
- Files are limited to 25 MB, because the whole Base64 text has to be held and displayed in the page.
- Decoding binary data as text produces unreadable characters; use the file decoder for images, PDFs and other binary data.
- Base64 does not compress or protect data — it makes it about a third larger.
How your data is handled
Encoding and decoding take place in your browser. Text and files are never uploaded.
Frequently asked questions
Is Base64 a form of encryption?
No. It is a reversible encoding that anyone can decode instantly. Never use it to hide passwords or sensitive information.
Why does my decoded text show strange characters?
Either the original was not UTF-8 text, or the Base64 is incomplete or damaged. If the data was a file, use the “Decode Base64 to a file” section and give it the correct file extension.
What is the difference between Base64 and base64url?
base64url replaces + with - and / with _, and usually omits padding, so the result can be used in URLs and file names without further encoding. JSON Web Tokens use base64url.
Should I embed images as Base64 data URIs?
Only very small images, such as tiny icons. Base64 makes files about a third larger and prevents the browser from caching the image separately, so larger images are better served as normal files.