How to use the Base64 encoder and decoder
- Choose Encode to turn text or a file into Base64, or Decode to turn Base64 back into readable text or a downloadable file.
- For text, type or paste into the left box. The output updates as you type.
- For a file, switch the input to File and choose or drop it. Images get a preview.
- Tick URL-safe if the value goes into a web address or a JSON Web Token, or tick line wrapping for email (MIME) use.
- Copy the result, download it, or press “Use output as input” to reverse the operation.
How Base64 encoding works
Computers store everything as bytes, and many systems, such as email, URLs and JSON, only carry plain text safely. Base64 bridges the two. It reads the data 3 bytes (24 bits) at a time, splits those 24 bits into four 6-bit groups, and writes each group as one of 64 characters: A–Z, a–z, 0–9, + and /. If the data does not divide evenly by 3, one or two = signs pad the end.
Worked example
The word “café” has four letters but 5 bytes in UTF-8, because “é” takes two bytes: 63 61 66 C3 A9. Encoding those 5 bytes gives Y2Fmw6k=, which is 8 characters: two full groups of four, with one = for padding.
A simpler encoder that skips the UTF-8 step would fail on this word or produce a different, wrong result. That is the most common Base64 bug in web code.
Base64 is encoding, not encryption
Anyone can decode Base64 instantly; it hides nothing. Basic authentication headers, JSON Web Tokens and email attachments all use it purely for transport. Never treat a Base64 string as a safe place for passwords or private data.
Anatomy of a data URI
A data URI has three parts: the scheme data:, the media type such as image/png, and ;base64, followed by the encoded bytes. For example, data:image/png;base64,iVBORw0KGgo… can go straight into an <img src> attribute or a CSS url(). If the media type is wrong, browsers may refuse to display the file, so the tool fills it in from the file you chose.
Key features
- Correct UTF-8 handling for every language and emoji.
- Standard and URL-safe alphabets, with or without padding.
- File to Base64 or data URI, and Base64 back to a downloadable file with the right extension for common types.
- Accepts input with line breaks, missing padding or a data URI prefix.
- Works offline; files are read locally and never uploaded.
Practical use cases
Embedding small images. A data URI lets you place an icon directly in CSS or HTML, saving a request. Keep it for files under a few kilobytes, since Base64 makes them a third larger and they cannot be cached separately.
Reading tokens. The middle part of a JSON Web Token is URL-safe Base64. Paste it here in decode mode to read the claims, such as the expiry time.
APIs and config. Some APIs expect file uploads or credentials as Base64 inside JSON, and Kubernetes stores secret values in Base64.