How to Encode and Decode Base64 Online
Updated 2026-06-21
To encode Base64, paste your text or drop a file into the Base64 Encoder / Decoder, and the encoded output appears instantly. To decode, switch to Decode mode and paste a Base64 string — you get the original text, an image preview, or a downloadable file back. Everything runs in your browser, so nothing is uploaded.
How to encode text to Base64
- Open the tool and keep Mode set to Encode with input type Text.
- Type or paste your content into the input box.
- Copy the Base64 result from the output panel.
Base64 turns any bytes into the 64 safe characters A–Z, a–z, 0–9, plus the symbols + and /, padding with = at the end. Because it represents 3 bytes with 4 characters, the output is about 33% larger than the input — the tool shows you that overhead live.
Two toggles cover common edge cases:
- URL-safe swaps + and / for - and _ and drops the padding, so the string is safe inside URLs and JSON Web Tokens.
- Wrap 76 breaks the output into 76-character lines, matching MIME email and PEM key formatting.
How to encode a file or build a data URI
Switch the input type to File and choose any file up to 50 MB. The tool reads it locally and returns the raw Base64 plus a ready-to-use data URI in the form data:image/png;base64,followed by the data. For images you also get drop-in snippets:
- An HTML img tag with the data URI inline.
- A CSS background-image rule.
- A favicon link tag, a Markdown image, or a JSON object.
Inlining small icons this way removes an extra network request, though large images are usually better left as normal files.
How to decode Base64 back
Choose Decode and paste the Base64 string. The tool accepts standard, URL-safe, and unpadded input, and it automatically strips a leading data: prefix, so you can paste a full data URI without trimming it first.
If the bytes are valid UTF-8 text, you see the decoded text and can copy or download it. If the input is actually an image, the tool sniffs the type from its magic bytes and shows a live preview with the correct file extension. When the decoded bytes are not valid text, you will see a warning about the � replacement character — toggle Treat output as binary (download) to save the exact original bytes instead.
Common pitfalls
- Invalid characters — a stray space or a line break is fine (whitespace is ignored), but symbols outside the Base64 alphabet trigger an "Input is not valid base64" error.
- Mistaking URL-safe for standard — if a token uses - and _, decode it here directly; the tool normalizes it automatically.
- Binary decoded as text — garbled output with � means you are looking at a file, not text. Use binary mode to download it.
Because this is a 100% client-side tool, you can safely encode or decode tokens, keys, and private files without sending them anywhere. Encode or decode your data now with the Base64 Encoder / Decoder.