Skip to main content
KON Tools — Kit of Online Needs
Developer Tools Runs 100% in Browser

Base64 Encoder & Decoder — Safe UTF-8 Text Converter

Encode text to Base64 or decode Base64 strings back cleanly in your browser. Safely handles UTF-8 Unicode emojis, non-Latin text, and URL-safe tokens offline.

0 chars / 0 bytes
0 chars

How to Use This Tool

  1. 1 Select Encode (Text to Base64) or Decode (Base64 to Text) at the top bar.
  2. 2 Type or paste plain UTF-8 text or an existing Base64 string into the input box.
  3. 3 Enable URL-safe Base64 whenever generating tokens meant for URLs or JWT-compatible strings.
  4. 4 Click Swap Mode & Text to reverse-check round trips immediately or Copy Result with one click.

Reliable UTF-8 Base64 Encoding Without Character Corruption

Base64 translates arbitrary binary octets into 64 printable ASCII characters (A–Z, a–z, 0–9, +, /) so binary blobs, certificates, JSON configuration snippets, and structured payloads survive transport through HTTP headers, YAML configs, or legacy email relays cleanly.

However, a persistent pain point in quick web converters stems from browser JavaScript’s built-in btoa() and atob() functions operating purely on UTF-16 code units clipped to 8 bits. Passing accented French words, CJK scripts, Arabic text, or emoji characters straight into naive btoa() either crashes immediately or outputs corrupted mojibake when decoded later on a backend server.

Proper TextEncoder & TextDecoder Pipeline

Our converter encodes every input string into a true UTF-8 byte stream (Uint8Array) via TextEncoder before Base64 grouping, and validates decoded byte streams strictly with new TextDecoder('utf-8', { fatal: true }). What goes in as Unicode comes back identically byte-for-byte.

Standard vs. URL-Safe Mode (RFC 4648 §5)

  • Standard Base64: Best for HTTP Basic Auth headers, Docker registry credentials, data URIs, and MIME attachments where +, /, and = padding are expected.
  • URL-Safe Base64: Ideal for query parameters, webhook verification links, and inspecting decoded JWT header or payload segments smoothly with zero manual padding fixes during Decode.

Frequently Asked Questions

Why does naive browser btoa() fail on emojis or accented characters?

Legacy btoa() only supports single-byte Latin-1 characters and throws InvalidCharacterError on multi-byte UTF-8 text. We encode strings via TextEncoder first so Unicode scripts and emojis convert accurately.

What is the difference between standard Base64 and URL-safe Base64?

URL-safe Base64 swaps + and / characters for - and _ while stripping trailing = padding so tokens transmit cleanly in query strings and filenames without percent-encoding.

Can decoding restore corrupted or non-Base64 strings?

When pasted text contains invalid Base64 characters or malformed UTF-8 byte sequences, the converter halts safely and displays an explicit diagnostic message instead of garbling output.