Base64 Encode & Decode

Base64 turns bytes into text using 64 characters (A–Z, a–z, 0–9, + and /), so binary data can travel safely through JSON, email and URLs. Paste text to encode it, or paste Base64 to decode it. UTF-8 and URL-safe Base64URL are supported, and nothing leaves your browser.

Output

How Base64 works

Base64 reads the input three bytes (24 bits) at a time and splits them into four groups of six bits. Each six-bit number, from 0 to 63, maps to one character of the alphabet A–Z a–z 0–9 + /. If the input does not divide evenly into threes, the output is padded with one or two = signs.

"Man" → 01001101 01100001 01101110 → 010011 010110 000101 101110 → TWFu

Examples

TextBase64Base64URL
helloaGVsbG8=aGVsbG8
Hello, world!SGVsbG8sIHdvcmxkIQ==SGVsbG8sIHdvcmxkIQ
☕4piV4piV
<<??>>PDw/Pz4+PDw_Pz4-

In code

// Browser and Node 16+: UTF-8 safe
const bytes = new TextEncoder().encode('Hello, world! ☕');
const b64 = btoa(String.fromCharCode(...bytes));

// Node.js
Buffer.from('Hello', 'utf8').toString('base64');      // SGVsbG8=
Buffer.from('SGVsbG8=', 'base64').toString('utf8');   // Hello
Buffer.from('Hello').toString('base64url');           // SGVsbG8

Frequently asked questions

Is Base64 encryption?

No. Base64 is an encoding: anyone can decode it without a key. It turns binary data into 64 safe text characters so it can travel through systems built for text, such as JSON, email or URLs. Never use it to hide passwords or secrets.

Why is Base64 output bigger than the input?

Base64 turns every 3 bytes into 4 characters, so output is about 33% larger than the input, plus up to two "=" padding characters at the end.

What is URL-safe Base64?

Standard Base64 uses "+" and "/", which have special meanings in URLs. The URL-safe variant (Base64URL, RFC 4648 section 5) uses "-" and "_" instead and usually drops the "=" padding. JWTs use Base64URL.

Why does btoa() fail on my text?

The browser’s btoa() only accepts characters in the Latin-1 range, so emoji or non-Latin text throw an error. Encode the text to UTF-8 bytes first, which is what this tool does: new TextEncoder().encode(text), then Base64 the bytes.

Related tools