Convert UTF-8 to Base64
Encode UTF-8 text to standard / URL-safe / MIME Base64 with padding, line-wrap, data-URI. Bidirectional, emoji-safe. Free, client-side, instant, secure.
- Runs in your browser
- Nothing uploaded
- Free, no sign-up
Encode UTF-8 text to Base64 in 3 variants - standard (+ /), URL-safe (- _), and MIME (76-char line wrap). Toggle padding, set custom line width, or output as a data: URI. Multi-byte characters and emoji round-trip correctly via TextEncoder.
3-byte block → 4-char quartet
How to Use Convert UTF-8 to Base64
- Paste UTF-8 text - ASCII, accented Latin, CJK, emoji, anything.
- Pick a variant. Standard (RFC 4648 §4) is the default; URL-safe replaces
+with-and/with_so the result can drop directly into a URL/filename; MIME (RFC 2045) wraps at 76 chars with CRLF for email bodies. - Toggle = padding. Padding makes the output length a multiple of 4; some decoders require it, others tolerate either. Default on for compatibility.
- Set a custom line wrap if needed. For non-MIME variants, default is none (single line). 0 = no wrap.
- Check Output as data: URI to wrap as
data:text/plain;base64,...ready to paste into an HTMLsrc=or CSSurl(). - Swap direction to decode any Base64 back to text - accepts all variants, padding-optional, whitespace-tolerant.
Frequently Asked Questions
What’s the difference between the three variants?
All three use the same 64-character alphabet for the first 62 positions (A-Z a-z 0-9). They differ at positions 62 and 63: Standard uses + /, URL-safe uses - _, MIME uses + / but wraps lines at 76 chars with CRLF for fitting into 80-column email transports. URL-safe is the only variant whose output is safe to paste directly into URL paths/queries and filenames.
Why does emoji work here when other Base64 tools fail?
Many simple Base64 implementations call btoa(text) directly. That throws on any character above U+00FF because btoa only accepts binary strings (Latin-1). This tool calls new TextEncoder().encode(text) first to get the UTF-8 byte array, then passes those bytes through btoa – so any Unicode character including emoji round-trips correctly.
What does the 3-byte block grid show?
Base64 maps every 3 input bytes (24 bits) to 4 output characters (each carrying 6 bits). The grid shows each 3-byte block with its hex / decimal bytes and the resulting 4-character quartet – useful for debugging encoding output by hand or showing students how Base64 works.
What’s the size overhead?
Exactly 4/3 = 1.33× for the encoded bytes vs source bytes, plus padding (up to 2 chars). For ASCII source text it’s 4/3 ≈ 1.33× the input character count. For UTF-8 text with many multi-byte chars (emoji = 4 bytes each), the overhead per character can look much higher: 🌍 (1 input char, 4 UTF-8 bytes) → 8 Base64 chars including padding = 8× the input char count.
Can I skip padding?
Yes – toggle “Include = padding” off. Some systems (JWT, modern URL-safe Base64 spec, OAuth) explicitly forbid padding. The decoder accepts both padded and unpadded input, adding padding back during decode for atob.
What goes wrong if I decode non-UTF-8 bytes?
The decoder uses TextDecoder('utf-8', {fatal: true}), so if the decoded bytes are not valid UTF-8 (e.g., you Base64-encoded a JPEG or some arbitrary binary), it throws “Decoded bytes are not valid UTF-8”. For arbitrary binary, you need a different tool that doesn’t try to interpret the bytes as text.
What about line endings in MIME mode?
RFC 2045 requires CRLF (rn) every 76 chars. This tool emits CRLF for MIME variant and LF (n) for the custom-wrap option. The decoder strips all whitespace including line breaks before processing.
Is Base64 encryption?
No. It’s an encoding scheme designed to represent binary data in 7-bit ASCII. Anyone with the encoded string can decode it instantly. Don’t confuse Base64 with cryptographic security – if you need confidentiality, encrypt first (AES, RSA), then Base64-encode the ciphertext.
Does the data: URI work in browsers?
Yes for text/plain (what this tool defaults to). For images, you’d want a file converter that reads the bytes directly. The data URI here just wraps the Base64 in the standard prefix so you can paste into an HTML src attribute and the browser will decode.
Is the text uploaded anywhere?
No. Everything runs client-side via TextEncoder, btoa, atob, and TextDecoder. About 18 KB of code.
Related Tools
Base64 to UTF-8 Decoder →
Decode Base64 to UTF-8 text - handles emoji, CJK, BOM-stripping, URL-safe variants. Free, client-side,…
Binary to UTF-8 Decoder →
Binary to UTF-8 Text Decoder handles emoji, CJK, accents, strips BOM, counts replacement chars.…
Convert Arbitrary Base to UTF-8 →
Decode numeric tokens in any base (2-36) as UTF-8 bytes - multi-byte emoji and…
Convert Bytes to UTF-8 →
Convert Bytes to UTF-8 Decode decimal/hex/binary byte values to UTF-8 text - emoji, CJK,…
Code Points to UTF-8 Converter Free →
Free online Unicode code points to UTF-8 converter. Shows actual UTF-8 byte sequences per…
Convert Data URI to UTF-8 →
online Data URI to UTF-8 decoder with byte-breakdown panel for emoji and CJK. Client-side,…
Convert Decimal to UTF-8 →
online decimal to UTF-8 text decoder. Byte-mode (raw UTF-8 bytes) and codepoint-mode. Client-side, instant,…
Convert Hexadecimal to UTF-8 →
Decode hex to UTF-8 text with byte-structural breakdown. Handles ASCII, Latin, CJK, emoji. Batch…
Convert HTML Entities to UTF-8 →
Decode HTML entities to UTF-8 with per-character byte breakdown. Named, decimal, hex. Free, offline,…
Convert Octal to UTF-8 →
Decode octal byte sequences to UTF-8 text, encode UTF-8 to octal. C-escape support, multi-byte.…
Convert UTF-16 to UTF-8 →
Convert UTF-16 code units to UTF-8 text and bytes. 3 formats, BE/LE, BOM, surrogate…
Convert UTF-32 to UTF-8 →
Convert UTF-32 code points to UTF-8 text and bytes. 3 formats, BE/LE, BOM, strict…