Base64 Encoder & Decoder

Encode text or files to Base64 and decode them back — entirely in your browser

 
 
Options:

Advanced tools

Inspect, convert in bulk, and build the wrappers that use Base64.

Base64 Inspector

Paste a Base64 string to check whether it is valid, which variant it uses, and what the raw bytes actually are — without decoding it into your clipboard first.

Try:

Tip: a string of n bytes always encodes to 4 × ceil(n / 3) characters — 100 bytes becomes 136 characters.

Batch converter

One value per line, converted independently. A malformed line reports its own error rather than breaking the whole batch.

Results
Results appear here, one per input line…

HTTP Basic Auth header

Build or read the Authorization header from RFC 7617.


Data URI builder

Inline an asset directly into CSS or HTML — no extra request.

Preview of the data URI
182 characters
data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiI+PGNpcmNsZSBjeD0iMTYiIGN5PSIxNiIgcj0iMTQiIGZpbGw9IiM2MzY2ZjEiLz48L3N2Zz4=

Do this in code

The correct, UTF-8-safe way in each language.

Encode
// Text -> Base64 (UTF-8 safe)
const bytes = new TextEncoder().encode(text);
const bin = String.fromCharCode(...bytes);
const b64 = btoa(bin);

// URL-safe variant
const urlSafe = b64.replace(/\+/g, '-')
                   .replace(/\//g, '_')
                   .replace(/=+$/, '');
Decode
// Base64 -> text (UTF-8 safe)
const bin = atob(b64);
const bytes = Uint8Array.from(bin, c => c.charCodeAt(0));
const text = new TextDecoder().decode(bytes);

How it works

Three bytes in, four characters out.

Input     M         a         n
ASCII     77        97        110
Bits      01001101  01100001  01101110
Regroup   010011  010110  000101  101110
Index     19      22      5       46
Base64    T       W       F       u

The 64-character alphabet:

Base64 index to character mapping
015ABCDEFGHIJKLMNOP
1631QRSTUVWXYZabcdef
3247ghijklmnopqrstuv
4863wxyz0123456789+/
Standard
A–Z a–z 0–9 + /
URL-safe
A–Z a–z 0–9 - _
Encoded size
4 × ceil(n / 3)
Overhead
~33%

Common questions

Is Base64 encryption? Is it safe for passwords?

No. Base64 is an encoding, not encryption — it is trivially reversible by anyone, with no key involved. It exists to move binary data through channels that only accept text, such as email bodies, JSON fields, and URLs. Never use it to protect secrets. An HTTP Basic auth header is Base64 precisely because it is not secret; that is why it must only be sent over HTTPS.

Why does my encoded string end in = or ==?

Base64 works on 3-byte groups, turning each into 4 characters. When the input length is not a multiple of 3, the final group is padded with = to keep the output a multiple of 4. One leftover byte produces ==, two produce =. The padding carries no data — it only tells strict decoders where the input ended.

What is URL-safe Base64, and when do I need it?

The standard alphabet includes + and /, which have special meaning in URLs and file paths — / splits path segments and + can be read as a space in query strings. RFC 4648 §5 defines a variant that uses - and _ instead, usually with the padding stripped since = also needs escaping. This is what JWTs use. The decoder on this page accepts either variant automatically.

How much bigger does Base64 make my data?

About 33% larger: every 3 bytes become 4 characters, so n bytes produce 4 × ceil(n / 3) characters. A 100KB image becomes roughly 133KB of text. If line wrapping is enabled, the newlines add a further ~1.4%. This is why inlining large images as data URIs is usually a false economy — you save a request but send more bytes and lose separate caching.

Why does my decode fail with an "invalid length" error?

A valid Base64 string never has a length that leaves a remainder of 1 when divided by 4, because a single leftover character encodes only 6 bits — less than one byte. Getting this error almost always means the string was truncated in transit, or an extra character was picked up when copying. Check the start and end of what you pasted.

I decoded something and got garbage characters. What happened?

The Base64 was probably valid, but the bytes underneath are not text — they are an image, an archive, or another binary format. Text decoding only makes sense when the original data was text. Use the Inspector above to see the detected file type and a hex view, or switch to File mode to download it properly.

Does anything I paste here get uploaded?

No. Every conversion on this page runs in your browser using local JavaScript. There is no API call, no analytics on your input, and nothing is stored. You can confirm it by opening DevTools, switching to the Network tab, and watching while you encode — or by disconnecting from the network, since the page keeps working offline.

Your data stays private. All processing happens locally in your browser. No data is collected, stored, or sent to any server.