Base64 Text & URL-Safe Encoder/Decoder

Encoding text as base64 for auth headers, data URIs or JWT segments? Encode, decode, and switch to URL-safe — all locally, Unicode included.

Embed this tool on your website / blog No code required · Copy and paste
HTML Embed Code (iframe):
<iframe src="https://lucentool.com/base64-tools" width="100%" height="650" style="border:1px solid #e5e0d8;border-radius:12px;max-width:850px;width:100%;" frameborder="0"></iframe>
<div style="font-size:12px;color:#78716c;margin-top:6px;font-family:sans-serif;">Powered by <a href="https://lucentool.com/base64-tools" target="_blank" style="color:#c85a32;text-decoration:none;">Lucentool - Base64 Text & URL-Safe Encoder/Decoder</a></div>

What base64 is for

Base64 encodes binary data into 64 printable ASCII characters so it survives text-only channels: email attachments (MIME), HTTP Basic auth (user:pass), data URIs in CSS/HTML (data:image/png;base64,...), and the base64url segments of JWTs. Every 3 bytes become 4 characters, so output is ~33% larger than input.

Standard vs URL-safe

Unicode note

Text is encoded as UTF-8 first, so emoji and CJK work correctly both ways — a common bug with naive encoders that mangle non-ASCII input.

Pair with the JWT Decoder if you're working with tokens (all three segments are exactly base64url).

Edge cases and hard limits

Text and Base64 are converted through bytes rather than through btoa alone, because btoa rejects anything above code point 255. utf8ToB64() encodes the string to UTF-8 bytes first, builds a binary string from them and only then base64-encodes; b64ToUtf8() reverses it with atob and a TextDecoder, so a Chinese character or an emoji survives the round trip instead of throwing an invalid-character error.

Formats, sizes and other limits

The encoding is standard Base64 with padding, not the URL-safe alphabet — a value containing + or / will break if placed in a query string. Whitespace inside the input is stripped before decoding, which is convenient for copied block text and dangerous if the whitespace was meaningful. Very large strings hit the argument limit of the binary-string construction, so multi-megabyte payloads belong in the file variant of the tool.

Privacy: processed in your browser

The string is converted to bytes and back inside this tab using the browser’s own encoder; nothing is transmitted, so a token you are debugging does not leave the machine.

Frequently asked questions

Why does Chinese text fail elsewhere?

Because plain btoa only handles Latin-1. This page converts to UTF-8 bytes first, which is why CJK and emoji survive.

Is it URL-safe Base64?

No. Standard alphabet with + and /. If the value goes into a query string, use the URL encoder instead.

Can it decode a JWT payload?

It can decode the middle segment once you remove the URL-safe substitutions (- to +, _ to /). The JWT decoder does that for you.