Skip to content
nah

Base64 Encoder / Decoder

Encode or decode Base64 for text and files — UTF-8 safe, URL-safe option, fully in-browser.

100% in your browser — files never leave your device

Base64 output

Output appears here.

Encode a file

What this Base64 tool does differently

Standard Base64 uses 64 printable characters to represent arbitrary bytes as ASCII text, which is why it shows up in data URIs, email attachments, and JWT segments. This tool encodes by converting your text to UTF-8 bytes first, then Base64-encoding those bytes — the reverse of the naive approach most quick implementations use.

The naive shortcut — calling btoa() directly on a string — only works for Latin-1 characters (code points 0–255). Paste in an emoji or a CJK character and btoa() throws, because those characters need more than one byte. Encoding the UTF-8 byte array first sidesteps that failure entirely, so any Unicode input round-trips correctly.

The URL-safe toggle swaps + for -, / for _, and strips = padding, which matters when the output has to sit inside a query string or path segment without additional escaping. Base64 is an encoding, not encryption — anyone can decode it, so it isn't a place to hide secrets.

Frequently asked questions

Is my data uploaded anywhere?

No. All encoding and decoding runs entirely in your browser using built-in JavaScript APIs. Nothing leaves your device.

What is URL-safe Base64?

Standard Base64 uses + and / characters that have special meaning in URLs. URL-safe Base64 replaces + with - and / with _, and strips = padding — making the output safe to include in query strings and path segments without further escaping.

Why does naive btoa() break on non-ASCII text?

btoa() only handles Latin-1 (byte values 0–255). Multi-byte UTF-8 characters like emoji or CJK glyphs have code points above 255, which throws. This tool first encodes text to a UTF-8 byte array, then Base64-encodes those bytes — so any Unicode string works correctly.

Related tools