How to use
- Choose a source: Text or File / Image.
- In Text mode, pick Encode or Decode and type the content; the result updates in real time.
- Tick Base64URL to produce the URL-safe variant without padding.
- Use Swap to send the result back to the input and run the opposite operation.
- In File mode, select a file to get its Data URL and raw Base64, with a preview for images.
Use cases
- Embedding icons and small images in CSS or HTML via data:image/...;base64.
- Building HTTP Basic Auth headers (user:password in Base64).
- Inspecting JWT segments, which use Base64URL.
- Carrying binary data in JSON fields or environment variables that only accept text.
Technical concepts
How Base64 works
Base64 groups input bytes into blocks of 3 (24 bits) and splits them into 4 groups of 6 bits, each mapped to one of 64 characters: A–Z, a–z, 0–9, + and /. When the input is not a multiple of 3, the = sign pads the last block. The output is about 33% larger than the input.
Base64URL
Defined in RFC 4648 section 5, it replaces + with - and / with _ and usually drops the padding, so it can be used in URLs, file names and JWTs without extra escaping. The decoder on this page accepts both variants automatically.
UTF-8 and btoa
The browser's btoa function only accepts Latin-1 characters. For accents and emoji, the text is first converted to UTF-8 bytes with TextEncoder and then encoded; when decoding, the bytes are validated as strict UTF-8.
Frequently asked questions
Is Base64 encryption?
No. Base64 is a reversible encoding with no key. Anyone can decode it; never use it to protect passwords or sensitive data.
Why do I get a UTF-8 error when decoding?
The decoded content is binary (an image, PDF or archive) rather than text. The bytes are correct, but they cannot be displayed as text.
When should I use a Data URL for images?
For very small files, such as icons of a few KB, to save an HTTP request. For larger images, the 33% size increase and lack of caching make a separate file more efficient.