Base64 Encoder / Decoder
Encode text or files to Base64 (standard or URL-safe), or decode Base64, Base64url and line-wrapped MIME/PEM data back to text — or to a downloadable file when the result is binary. Everything runs in your browser.
…or drop any file to encode it
Images, PDFs, certificates, anything — max 15 MB
What this Base64 tool does
Base64 (RFC 4648) represents arbitrary bytes with 64 printable characters — A–Z, a–z, 0–9, + and / — so binary data can travel through channels built for text: JSON fields, email bodies, HTTP headers, environment variables and configuration files. You meet it when you inspect an Authorization: Basic header, read a Kubernetes secret, copy a PEM certificate or debug an API that returns a file inside JSON.
This page encodes text as UTF-8 and any file you drop as raw bytes, and decodes in the other direction. The decoder is deliberately forgiving: it accepts line-wrapped MIME and PEM data, the URL-safe alphabet used by JWTs, strings whose = padding was stripped and complete data: URIs. When the decoded bytes are not text, you get a hex dump and a download instead of a misleading error.
How to use it
- Choose Encode or Decode at the top.
- Type or paste into the input box. In Encode mode you can instead drop a file on the area below the box. The result updates as you type — there is no button to press.
- When encoding, tick URL-safe for Base64url output, or Wrap lines at 76 characters for MIME-style output.
- Use Copy or Download to take the result. Swap sends the output back as input in the opposite mode, which is a quick round-trip check.
- If the decoded result is binary, use Download file. For text results, Show hex reveals the exact bytes, which helps spot invisible characters or encoding mix-ups.
Worked example
Encoding Hello, World! produces the standard and URL-safe forms below. The 13 input bytes are not a multiple of 3, so standard output ends with two padding characters:
Standard: SGVsbG8sIFdvcmxkIQ== URL-safe: SGVsbG8sIFdvcmxkIQ
Text with non-ASCII characters is encoded as UTF-8 first. The emoji 🌍 alone is four bytes (F0 9F 8C 8D) and becomes 8J+MjQ==. Pasting 8J-MjQ (URL-safe, no padding) into Decode returns the same emoji, because the decoder normalises the alphabet and padding before decoding.
Options and output explained
- URL-safe — swaps
+for-and/for_, and removes padding. Use it for URLs, query parameters, filenames, JWT segments and many cloud APIs. - Wrap lines at 76 characters — inserts CRLF line breaks, as email (MIME) expects. PEM files use 64 characters per line, so do not use this option to rebuild a certificate.
- Byte counter — the input header shows UTF-8 bytes, not characters; an accented letter is two bytes and most emoji are four. The output footer shows the byte → character expansion (about 4/3).
- Hex view — 16 bytes per row with offsets and an ASCII column. Only the first 4,096 bytes are displayed; Download always returns the complete data.
Limitations
Files up to 15 MB can be encoded; very large outputs make the browser slow to render, so download them instead of copying. Text is always encoded as UTF-8 — if a system expects Latin-1 or UTF-16 bytes, the Base64 will differ. The decoder ignores whitespace anywhere in the input, which is what you want for wrapped data, but means spaces cannot be used as meaningful characters. Base64 provides no integrity check: a truncated string may still decode to something.
Tips and common mistakes
- For PEM keys or certificates, paste only the lines between
-----BEGIN …-----and-----END …-----; the header lines contain spaces and dashes that are not Base64. - A JWT is three Base64url parts separated by dots — decode one part at a time, or use the JWT Decoder for the whole token.
- To turn a pasted image string back into a picture with a preview, the Base64 to Image tool is more convenient; for the reverse, use Image to Base64.
- If a decoded value looks almost right but has odd characters such as
é, the original was probably encoded from Latin-1 text, not UTF-8. Check the bytes with Show hex.
Frequently Asked Questions
Is my data sent to your servers?
No. Encoding and decoding run entirely in your browser with the built-in btoa/atob and TextEncoder/TextDecoder APIs. Text and files you load never leave your device.
Is Base64 the same as encryption?
No. Base64 is a reversible encoding with no key, so anyone who has the string can decode it. Never rely on it to hide passwords, tokens or personal data.
What is the difference between Base64 and Base64url?
Base64url (RFC 4648 §5) replaces + with - and / with _ and usually drops the = padding, so the result is safe in URLs, filenames and JWTs. Tick URL-safe to produce it; the decoder accepts both alphabets automatically.
Why does my Base64 string fail to decode in other tools?
Common causes are line breaks from MIME or PEM wrapping, URL-safe characters, missing = padding or a data: prefix. This decoder strips whitespace and the data: prefix, maps - and _ back, and restores padding, then tells you exactly which character is invalid if it still fails.
What happens if the decoded data is not text?
If the bytes are not valid UTF-8 (an image, PDF, ZIP or random key material), the tool shows a hex dump instead of garbled text and offers Download file so you get the original binary back, with an extension guessed from its first bytes.
Why does Base64 output end with = or ==?
Base64 turns every 3 bytes into 4 characters. When the input length is not a multiple of 3, one or two = characters pad the output to a multiple of 4. Base64url output normally omits them.
Related tools
- JWT Decoder & ValidatorDecode JSON Web Tokens (JWT) and inspect their header, payload, claims, and expiry status.
- URL Encoder / DecoderEncode or decode URLs and query string parameters using percent-encoding (RFC 3986).
- Image to Base64Convert images to Base64 encoded strings
- Base64 to Image DecoderDecode Base64 strings back to images. Preview the image live and download it as PNG, JPEG, or WebP.
- HTML Entities EncoderEncode and decode HTML entities
- Base32 Encoder/DecoderEncode and decode Base32 strings online
Found a bug or a wrong result? Report it.