How to decode or encode Base64
- Choose Decode to turn Base64 back into text, or Encode to turn text into Base64.
- Paste your input. The result updates as you type. Spaces and line breaks in Base64 are ignored, and a
data:…;base64,prefix is removed automatically. - When encoding, turn on URL-safe Base64 if the result goes into a URL, a file name or a token.
- Click Copy, or Use result as input to reverse the conversion and check the round trip.
- To embed an image or font in HTML or CSS, use File to Base64 to get a complete data URL.
What is Base64?
Base64 represents any bytes using only 64 safe characters: A–Z, a–z, 0–9, + and /. It exists because many systems, such as email, JSON, XML and URLs, were designed for text and can break raw binary data. Every 3 bytes (24 bits) become 4 characters of 6 bits each, so Base64 is about 33% larger than the original. When the input is not a multiple of 3 bytes, = signs pad the end.
Worked example
The text Hi! is three bytes: 72, 105 and 33, or in binary 01001000 01101001 00100001. Regrouped into 6-bit blocks this is 010010 000110 100100 100001 = 18, 6, 36, 33. In the Base64 alphabet those positions are S, G, k and h, so Hi! encodes to SGkh.
Characters outside English take more bytes in UTF-8. The letter é is two bytes (C3 A9) and encodes to w6k=; the waving-hand emoji 👋 is four bytes, which is why Hello, World! 👋 becomes the 24 characters SGVsbG8sIFdvcmxkISDwn5GL.
Unicode and invalid input
The browser functions btoa and atob only understand Latin-1 and throw an error on emoji or most non-English text. This tool converts text to UTF-8 bytes first, which is what almost every modern system expects. When decoding, it checks the input and tells you exactly what is wrong instead of returning garbage:
- Invalid character, with its position, for example a stray
*or a smart quote pasted from a document. - Wrong length: a single leftover character can never form a byte, so the input was cut off.
- Wrong padding:
=may only appear at the end, at most twice. - Not text: the bytes are valid Base64 but not UTF-8, usually an image or a PDF. You see the first bytes in hexadecimal;
ff d8 ff, for instance, is the start of a JPEG.
Tips
- Base64 is not security. Never use it to hide passwords or API keys; anyone can decode it in a second.
- JWT tokens are three URL-safe Base64 parts separated by dots. Paste one part at a time to read the header or payload.
- Data URLs are best for small files. Icons under a few kilobytes are fine inline; large images are faster as separate files that the browser can cache.
- Line breaks: email (MIME) wraps Base64 at 76 characters. The decoder ignores those breaks, so you can paste it as it is.
Frequently asked questions
Is Base64 encryption?
No. Base64 is an encoding that anyone can reverse instantly. It makes binary data safe to put in text formats, but it does not hide or protect anything. Use real encryption for secrets.
Why does my decoded text show strange characters on other sites?
Many decoders treat bytes as Latin-1, which garbles accents and emoji. This tool encodes and decodes text as UTF-8, so é, ü, 日本語 and 😀 come back exactly as they went in.
What is URL-safe Base64?
A variant that replaces + with - and / with _ and usually drops the = padding, so the result can be used in URLs, file names and JSON Web Tokens without escaping. The decoder accepts both variants.
Is my data uploaded?
No. Text and files are converted in your browser with built-in functions and never leave your device.