Base64 Encoder/Decoder
Encode and decode Base64 online with proper UTF-8, URL-safe output, file and image support, and image preview. Free, no sign-up, no uploads.
- Correct UTF-8 text
- URL-safe Base64
- Files & images
- Nothing uploaded
Your data is processed in your browser and never uploaded or saved.
🔒 Everything is calculated in your browser. No data is sent to any server.
When to use it
- Embedding small images: Convert an icon or small image to Base64 for a data URI in HTML or CSS, saving a network request.
- Reading a JWT: The middle part of a JWT is URL-safe Base64, so decoding it shows the data inside.
- API and email debugging: Decode Base64 from an API response or raw email source back to text or a file.
- Configs and authentication: Encode credentials or certificates as Base64 for HTTP Basic auth, Kubernetes Secrets and similar settings.
How to use
- Choose "Encode" or "Decode", then type text or paste Base64 on the left. The result appears instantly on the right, with text handled as UTF-8 so accents, CJK and emoji work.
- To turn a file or image into Base64, click "Open file". Tick "URL-safe" when the result goes into a URL or a JWT.
- Decoded text is shown directly, images get a preview, and any other file can be saved with "Download". "Swap" moves the result back to the input so you can convert the other way.
Worked example
Encoding Chinese text: 你好 ("hello") is 6 bytes in UTF-8 and encodes to 5L2g5aW9, 8 characters. Every 3 bytes become 4 Base64 characters, so 6 bytes give exactly 8 characters with no = padding.
URL-safe: <<???>> is 7 bytes. Standard Base64 gives PDw/Pz8+Pg==, and with URL-safe ticked it becomes PDw_Pz8-Pg, ready to drop into a URL. Paste that into Decode mode and you get <<???>> back.
Restoring an image: paste the data URI data:image/png;base64,iVBORw0KGgo… of a 1×1 PNG into Decode mode. The prefix is stripped automatically, 70 bytes are decoded and recognized as PNG, a preview appears, and "Download" saves it as decoded.png.
Reading the results
- After encoding you'll see something like "18 bytes → 24 characters". The first number is the UTF-8 byte count (CJK characters are usually 3 bytes, emoji 4), the second is the Base64 length, about 4/3 of the bytes rounded up to a multiple of 4.
- The trailing = signs are padding, from zero to two. URL-safe output usually leaves them out, which doesn't affect decoding.
- If the decoded bytes are valid UTF-8 text they're shown as text. Otherwise they're treated as a file and identified by their header as PNG, JPEG, GIF, WebP, PDF or ZIP, with a preview for images.
- When decoding fails, you'll see the line and column of the invalid character. Stray quotes, backslashes or smart punctuation picked up while copying are the usual cause.
How it works
- Text is first converted to UTF-8 bytes. Each group of 3 bytes (24 bits) is split into four 6-bit values that map to the 64 characters defined in RFC 4648 (A–Z, a–z, 0–9, + and /). A final group shorter than 3 bytes is padded with =.
- URL-safe follows RFC 4648 section 5: + becomes -, / becomes _, and the trailing = is removed, so the result is safe in URLs and file names.
- Decoding ignores spaces and line breaks, strips an RFC 2397 data URI prefix (data:…;base64,), accepts both standard and URL-safe characters, and adds any missing = automatically.
- Decoded bytes are shown as text if they're valid UTF-8 with no control characters other than tab and line breaks. Anything else is handled as a binary file.
Limitations
- Base64 is an encoding, not encryption. Anyone can decode it, so never rely on it to protect passwords or personal data.
- Files are limited to 10 MB, and the Base64 output is about a third larger than the original.
- Text is always treated as UTF-8. Data in other encodings, such as Windows-1252 or Shift_JIS, will decode as binary; download it and open it with the matching encoding.
- Only a handful of common file types are recognized. Other formats download with a .bin extension, which you'll need to rename.
FAQ
Why does my decoded Base64 look like gibberish or show as binary?
Usually the original data wasn't UTF-8 text. It may be in a legacy encoding such as Windows-1252 or Shift_JIS, or it may be an image or archive. When the bytes aren't valid UTF-8, this tool shows them as binary so you can download the file and open it with the right app.
What is URL-safe Base64 and when should I use it?
Standard Base64 uses + and /, which have special meanings in URLs. The URL-safe variant (base64url) uses - and _ instead and drops the trailing =. It's common in JWTs, URL parameters and file names. When decoding, this tool accepts both automatically.
How do I use a Base64 image in HTML or CSS?
Open the image with "Open file", copy the output, and add data:image/png;base64, in front (use image/jpeg for JPEGs), for example <img src="data:image/png;base64,iVBOR...">. You can also paste a whole data URI into Decode mode to get the image back.
Is my data uploaded?
No. Encoding, decoding, file reading and image previews all happen in your browser. Nothing is sent to a server or stored.
Is Base64 encryption?
No. Base64 is just an encoding: anyone can decode it back to the original, so it can’t protect passwords or confidential data.
Why does a file get bigger after Base64 encoding?
Base64 turns every 3 bytes into 4 characters, so the size grows by about 33%. That’s why it’s only suitable for small files.
How do I see what’s inside a JWT?
A JWT has three parts separated by dots. Choose “Decode”, tick “URL-safe” and paste the middle part to see its JSON content. This only decodes it; it can’t verify whether the signature is valid.
💬 Can't find an answer? Report a problem with this tool or send a suggestion
References
- RFC 4648: The Base16, Base32, and Base64 Data Encodings — IETF
- RFC 2397: The "data" URL scheme — IETF
- Base64 — MDN Web Docs