Base64 Encoder
Text and files to Base64 and back, including data URLs.
Encode a file or image
Produces a ready-to-paste data: URL for CSS, HTML or an API payload. The file is read locally and never uploaded.
What Base64 is for
Base64 rewrites arbitrary binary data using only 64 printable ASCII characters — A–Z, a–z, 0–9, + and /, with = as padding. It exists because many older transports — email headers, HTTP basic auth, JSON string fields, XML documents — can only carry text safely. Encoding a PNG or a protobuf message into Base64 lets it travel through those channels intact.
The cost is size: every 3 bytes become 4 characters, so encoded data is about 33% larger than the original. That trade is worth it for small assets and unavoidable for text-only protocols, but it is the wrong choice for large file transfers.
Base64 is not encryption
This is the single most important thing to know about it. Base64 is a reversible encoding with no key and no secret — anyone can decode it in one step, which is exactly what the Decode tab here does. Never use it to protect passwords, tokens or personal data. If you need confidentiality, encrypt first and encode the ciphertext afterwards if the transport requires text.
Standard vs URL-safe
Standard Base64 uses + and /, both of which have special meaning inside URLs and file names. The URL-safe variant defined in RFC 4648 §5 substitutes - and _ and usually drops the trailing = padding. JSON Web Tokens, OAuth state parameters and most modern APIs use the URL-safe form — tick the checkbox above to match it.
How to use it
- Choose Encode or Decode. Conversion happens as you type.
- Tick URL-safe if the value goes into a URL, a cookie or a JWT.
- Tick Wrap at 76 chars for MIME email bodies and PEM-style blocks.
- To embed an image, drop the file into the box below and copy the resulting data URL.
Frequently asked questions
Does it handle emoji, Chinese and other non-ASCII text?
Yes. Text is converted to UTF-8 bytes before encoding and back afterwards, so 你好, café and 🎉 all round-trip exactly. The naive btoa() call in a browser console fails on these — this tool does not.
What do the trailing equals signs mean?
They are padding. Base64 works on groups of three bytes; when the input length is not a multiple of three, one or two = characters mark the shortfall. One = means the last group held two bytes, two means it held one. Most decoders, including this one, accept unpadded input as well.
Should I inline images as data URLs?
For small assets — icons, a logo, a placeholder under roughly 5 KB — inlining removes an HTTP request and can be a net win. Beyond that the 33% size penalty and the loss of independent caching usually make a normal image file faster, because a data URL is re-downloaded with every page that embeds it.
Why does my decode fail?
Usually because the string contains characters outside the Base64 alphabet: a stray space, a line break that was not stripped, a URL-encoded %3D instead of =, or a URL-safe string being decoded as standard Base64. This tool normalises whitespace and both alphabets automatically and reports the first invalid character if one remains.
Are my files uploaded?
No. Files are read through the browser's FileReader API and encoded in the page. Nothing touches a server, so it is safe for confidential documents.