Skip to content
100% in your browser. Nothing you paste is uploaded — all processing runs locally. Read more →

Text → Base64

Paste text, copy the base64 output. UTF-8 by default, so any Unicode character roundtrips correctly.

🔒 100% client-side · no upload · no account

How encoding works

Base64 packs 3 input bytes into 4 ASCII characters from a 64-character alphabet (A-Z a-z 0-9 + /, plus = for padding). Every group of 3 bytes becomes 4 characters; if the input length isn't a multiple of 3, the final group is padded with = to fill out the 4 output positions.

The result is plain ASCII, so it survives any text-only transport (HTTP headers, email, JSON strings, query parameters with caveats).

Step by step

Text:        "Hi"
UTF-8 bytes: [0x48, 0x69]                      = 2 bytes
Padded:      [0x48, 0x69, 0x00] (pad to 3)     = 3 bytes
Binary:      01001000 01101001 00000000
Group by 6:  010010 000110 100100 000000
Lookup:      S      G       k      A
Mark padding:                       =
Result:      "SGk="

Sizing: how big does the output get?

For input of n bytes, output is ceil(n / 3) * 4 characters. That's exactly 4/3 ≈ 33% bigger. Concrete examples:

InputOutput (base64)Overhead
1 byte4 chars (e.g. QQ==)+300%
3 bytes4 chars+33%
1 KB~1.33 KB+33%
1 MB~1.33 MB+33%
10 KB image~13.3 KB data URI+33%

For tiny inputs the percentage overhead is dramatic but absolute size is small. For multi-MB binaries it's the reverse. Whenever you can use a binary transport instead (multipart upload, binary protocol), consider doing so.

When to URL-encode the result

Standard base64 uses + and /, both reserved in URL syntax. If your base64 string goes into:

Tick the "URL-safe" checkbox above to produce -/_ output, which avoids the URL-encoding step entirely.

In code

// JavaScript (UTF-8 safe)
const bytes = new TextEncoder().encode(text);
const b64 = btoa(String.fromCharCode(...bytes));

// JavaScript (Node 16+, much cleaner)
Buffer.from(text, "utf-8").toString("base64");
Buffer.from(text, "utf-8").toString("base64url");  // URL-safe

// Python
import base64
base64.b64encode(text.encode()).decode()
base64.urlsafe_b64encode(text.encode()).decode()

// Bash
printf "%s" "$text" | base64
printf "%s" "$text" | base64 | tr '+/' '-_' | tr -d '='   # url-safe

FAQ

What's the difference between this and the main page?

Same engine — this page frames the UX around 'I have text, give me base64.' The main page is symmetrical (type on either side); this one optimizes for one direction.

How does UTF-8 encoding work?

The browser's TextEncoder converts your string to UTF-8 bytes (a Uint8Array). Those bytes then go through btoa via a string-of-charcodes shim. The result handles every Unicode character correctly.

Should I use URL-safe encoding?

If the result will go into a URL, query string, JWT, or filename — yes. Otherwise standard base64 is fine. See the comparison.