Base64 Encode & Decode
Encode text or files to Base64 and decode it back. Runs in your browser.
About this base64 encode & decode
This Base64 tool encodes text and files to Base64 and decodes Base64 back to text or to the original file. Results update as you type, and the tool handles the messy input you find in real life: line breaks, data: URI prefixes, URL-safe characters and missing padding.
Text is always treated as UTF-8, so accented letters, non-Latin scripts and emoji round-trip correctly. When the decoded data is a file rather than text, the tool tells you what kind of file it is, shows a preview for images and lets you download it.
Everything runs in your browser. Tokens, keys and files you paste here are never sent to a server.
Features
Forgiving decoder
Paste Base64 with spaces, line breaks or a data:...;base64, prefix. URL-safe characters and missing = padding are fixed automatically, and each fix is listed so you know what changed.
Decode to a file
If the result isn't text, the tool detects common types such as PNG, JPEG, GIF, WebP, PDF, ZIP, GZIP, MP3 and MP4, previews images, and downloads the file with the right extension.
Full UTF-8 support
Text is converted to UTF-8 bytes before encoding, so every language and emoji works in both directions.
URL-safe output
One checkbox switches to the URL-safe alphabet with - and _ and no padding, the format used in JWTs and URL parameters.
File to Base64 or data URI
Choose any file up to 100 MB and get plain Base64 or a ready-to-use data URI for HTML and CSS. Optional 76-character line wrapping matches the email (MIME) format.
Clear error messages
Invalid input gets a specific message, such as which character position is wrong or that the text looks cut off.
Handles large output
Very long results show a preview on screen to keep the page responsive. Copy and Download always use the full result.
How to use the base64 encode & decode
- 1Choose Text or File.
- 2Pick Encode or Decode and paste. Results update as you type.
- 3Copy the result or download the decoded file.
When to use it
Inspect API data and tokens
Decode the payload part of a JWT or a Base64 field in a JSON response to see what it contains.
Recover an attachment
Turn a Base64 blob from an email source, a log or an API response back into the PDF or image it came from.
Embed small images
Convert an icon or small image to a data URI and paste it into HTML or CSS so it loads without a separate request.
Store binary data as text
Encode a key file or certificate so it fits in a config file, an environment variable or a JSON field.
How Base64 works and why it adds 33%
Base64 turns binary data into text using 64 safe characters: A to Z, a to z, 0 to 9, plus + and /. Each character carries 6 bits of data, while a byte has 8 bits. So every 3 bytes of input become 4 characters of output.
That 3 to 4 ratio is why Base64 is about 33% larger than the original. Line breaks, used in email, add a little more. When the input length isn't a multiple of 3, one or two = signs pad the end so the length is a multiple of 4.
Base64 is an encoding, not encryption. Anyone can decode it, so never use it to hide passwords or secrets.
Standard vs URL-safe Base64
The + and / characters have special meanings in URLs and file names. URL-safe Base64 replaces them with - and _, and usually drops the = padding. JWTs, many OAuth tokens and some APIs use this form.
When you decode, you don't need to choose. The tool spots URL-safe characters, converts them and adds any missing padding. When you encode, tick URL-safe if the result will go into a URL.
What a data URI is
A data URI puts a whole file inside a link. It starts with data:, then the file type, then ;base64, and then the encoded file, for example data:image/png;base64,iVBORw0KGgo...
Browsers can use a data URI anywhere a normal URL goes, such as an img src or a CSS background. It saves a network request, but the file gets about a third bigger and can't be cached on its own, so it suits small icons rather than large photos.
Why use Mavros
| Mavros | Typical upload sites | |
|---|---|---|
| Where data is processed | In your browser | Sent to a server, especially files |
| Messy input | Line breaks, data: prefix, URL-safe and padding fixed automatically | Fails with an invalid character error |
| Binary results | Type detected, image preview, download | Garbled text on screen |
| Unicode text | Always UTF-8 | Sometimes a charset you must pick |
| URL-safe variant | Same page, one checkbox | Often a separate tool |
Tips
- If decoding fails, check that you copied the whole string. A missing first or last character is the most common cause.
- Base64 strings that start with iVBORw0KGgo are PNG images, /9j/ are JPEGs and JVBERi0 are PDFs.
- For a JWT, decode only the middle part between the two dots. The tool handles the missing padding.
- Use Swap to send the result back into the input and flip the direction, which is a quick way to check a round trip.
- Keep data URIs for small files. Large images are better served as normal files.
Questions
How do I decode Base64 to a file?
Choose Text, pick Decode and paste the Base64 or data URI. If it holds a file, the tool shows its type and a Download button that saves it with the right extension.
Does it support Unicode and emoji?
Yes. Text is converted to UTF-8 bytes before encoding, so any language and emoji round-trips correctly.
Why is my Base64 invalid?
The text may be cut off, contain characters outside the Base64 alphabet, or mix standard and URL-safe characters. The error message tells you which problem it found and where.
Why is Base64 bigger than the original?
Every 3 bytes become 4 characters, so Base64 output is about 33% larger than the input.
Is Base64 encryption?
No. It is a reversible encoding that anyone can decode. Use real encryption to protect sensitive data.
What is URL-safe Base64?
A variant that uses - and _ instead of + and /, and often drops the = padding, so the result can sit in a URL. JWTs use it. This tool decodes it automatically.
How do I convert an image to Base64?
Choose File, add the image and pick Base64 or Data URI. Copy the result or download it as a text file.
Is there a file size limit?
Files up to 100 MB can be encoded. Larger files produce Base64 text too big for a browser to handle comfortably.
Is my data uploaded?
No. Encoding and decoding run in your browser. Nothing you paste or choose is sent to a server.