← Developer

Base64 Encode / Decode

Convert text and files to Base64 and back, UTF-8 safe, with URL-safe and MIME line-wrap options.

Text

Base64

Type on either side; the other updates live.

About this tool

This Base64 tool converts text and files to Base64 and back, entirely in your browser. Type or paste on either side of the text tab and the other side updates live, so it works as an encoder and a decoder at once. Non-ASCII text such as accented letters, CJK characters, and emoji is handled correctly because the text is first encoded as UTF-8 bytes. The file tab turns any file into a raw Base64 string or a data: URL for embedding images and fonts in HTML or CSS, and the download tab rebuilds a file from pasted Base64, guessing the type from a data: prefix or the file's magic bytes. It is for developers embedding assets, debugging API payloads and JWTs, and anyone who needs to move binary data through a text-only channel.

How it works

Base64 (RFC 4648 section 4) maps every 3 input bytes to 4 characters from a 64-symbol alphabet (A-Z, a-z, 0-9, +, /), padding the final group with = so the output length is a multiple of 4. The URL-safe variant (RFC 4648 section 5) swaps + and / for - and _ so the result can appear in URLs and filenames without percent-encoding. Text is converted to bytes with TextEncoder (UTF-8) before encoding and back with TextDecoder after decoding. The decoder is tolerant: it ignores whitespace and line breaks, accepts either alphabet, and infers missing padding from the length. Line wrapping at 76 characters follows the MIME convention in RFC 2045.

Frequently asked questions

Is Base64 encryption?

No. Base64 is a reversible encoding, not encryption; anyone can decode it instantly with no key. It exists so that arbitrary bytes can travel through systems that only handle text, such as email bodies, JSON strings, and URLs. Never rely on it to hide secrets.

Why is the Base64 output about a third longer than the input?

Every 3 bytes become 4 characters, so the output is 4/3 of the input size plus up to 2 padding characters. A 300 KB image becomes about 400 KB of Base64. Line wrapping adds another 2 bytes per 76 characters if CRLF line endings are used.

When should I use the URL-safe alphabet?

Use it whenever the encoded string is placed in a URL path or query string, a filename, or a JWT. Standard Base64 uses + and /, which have special meaning in URLs and would need percent-encoding; the URL-safe alphabet replaces them with - and _. Padding is usually dropped as well, as in JWTs (RFC 7515).

Why does decoding show garbled characters?

The decoded bytes are being interpreted as UTF-8 text. If the original data was binary (an image, a PDF) or text in another encoding such as Latin-1 or UTF-16, it will not display cleanly. Use the Base64 to file tab to download the bytes instead, and check the byte count matches what you expect.

Related tools

JSON Formatter · URL Encode / Decode · Regex Tester · Hash Generator · UUID Generator · JWT Decoder · HTML Entity Encoder · Color Converter · Password Generator · Number Base Converter · QR Code Generator · Chmod Calculator

Browse all Developer Tools, or go back to every free tool on HeroYears.