This free Base64 encoder and decoder converts text to Base64 and back, and turns files and images into data URLs. It handles Tamil, Hindi, emoji and other non-English text correctly, and everything happens in your browser.
How to use the Base64 encoder
- To encode text, type or paste it and choose Encode. To decode, paste Base64 and choose Decode. Text is handled as UTF-8, so any language works.
- Turn on URL-safe if the result will go into a URL or a file name.
- To convert a file, choose it in the file section. You get a Base64 data URL, and a preview if the file is an image.
- Press Copy to copy the result.
What Base64 is
Base64 is a way to write any binary data, such as an image or UTF-8 text, using only 64 safe characters: A–Z, a–z, 0–9, + and /, with = for padding. It is defined in RFC 4648. It is useful wherever a system only accepts plain text, such as JSON, email or HTML attributes.
The encoder takes the input 3 bytes (24 bits) at a time and writes them as 4 characters of 6 bits each. That is why Base64 output is about 33% larger than the original. When the input length is not a multiple of 3, one or two = signs pad the end.
| Input | UTF-8 bytes | Base64 |
|---|---|---|
Hi | 2 | SGk= |
Chennai | 7 | Q2hlbm5haQ== |
₹ | 3 | 4oK5 |
Watch out: Base64 is not encryption. Anyone can decode it in a second. Never use it to hide passwords, API keys or personal data.
URL-safe Base64
Standard Base64 uses + and /, which have special meanings in URLs and file paths. The URL-safe alphabet in section 5 of RFC 4648 replaces them with - and _. The = padding is often left out too, because the decoder can work out the length. You will see URL-safe Base64 in JSON Web Tokens and in many web addresses.
Why plain btoa() breaks on Indian text
The browser’s built-in btoa() only accepts characters with codes up to 255. Text such as வணக்கம் or ₹ makes it throw an error. The fix is to turn the text into UTF-8 bytes first, which is what this Base64 encoder does for you. In your own JavaScript you can do the same:
const bytes = new TextEncoder().encode('Price: ₹250');
const b64 = btoa(String.fromCharCode(...bytes));
console.log(b64); // UHJpY2U6IOKCuTI1MA==
const back = Uint8Array.from(atob(b64), c => c.charCodeAt(0));
console.log(new TextDecoder().decode(back)); // Price: ₹250Data URLs for images
A data URL puts a whole file inside a link, in the form data:image/png;base64,iVBORw0…. You can paste it into an <img src> or a CSS url(), and the browser shows the image without a separate download. This suits tiny icons and email templates. For normal photos it is a poor choice: the data is a third larger, cannot be cached on its own, and makes your HTML or CSS heavy. Our guide to image optimisation for the web explains better options, and the HTML images lesson covers the <img> element.
Learn more
- URL Encoder & Decoder
- JSON Formatter & Validator
- Image Compressor
- Image Optimisation for the Web: Formats, Sizes and Lazy Loading
- HTML Images
- Modern JavaScript (ES6+) Features
Frequently asked questions
Are my files uploaded?
No. The file is read by your browser and converted on your device. Nothing is sent to a server.
Why does my decoded text look like strange symbols?
The Base64 was probably made from text in a different encoding, or from a binary file such as an image. Decoding a file’s Base64 as text gives unreadable characters.
What do the = signs at the end mean?
They are padding. They show that the last group had only one or two bytes instead of three. URL-safe Base64 often leaves them out.
Can Base64 make my images smaller?
No. Base64 always makes data about a third larger. To make images smaller, compress or resize them instead.