Text & Writing Tools

Base64 Encoder & Decoder

Encode and decode UTF-8 text to standard or URL-safe Base64 format locally in your browser.

  • Free
  • No sign-up
  • Runs in your browser

Base64 Encoder

0.0 KB / 1 MB

Important: Base64 is Encoding, Not Encryption

Base64 is an open representation designed to transport binary data over text-only channels. It offers zero confidentiality. Never use Base64 alone to protect passwords, secret tokens, or private user data.

Runs in your browser. Your inputs never leave your device.

Quick Answer

Base64 encodes binary or text data into a 64-character ASCII alphabet (A–Z, a–z, 0–9, +, /) so it can travel safely across text-only protocols like email and HTTP. URL-safe Base64 swaps '+' and '/' for '-' and '_' to prevent URL delimiter collisions. Base64 is representation encoding, not encryption, and runs entirely in your browser with no network calls.

How to Use

  1. Select Encode or Decode Mode. Choose 'Encode to Base64' to transform plain text into Base64, or 'Decode from Base64' to extract original text.
  2. Enter Text or Base64 String. Type or paste your input into the source box. Unicode characters, emojis, and foreign alphabets are automatically handled.
  3. Toggle URL-Safe & Copy Result. Optionally enable the URL-Safe toggle to replace + and / with - and _, then copy the transformed output.

How & When to Use the Base64 Encoder / Decoder

  • Data URI Embedding: Convert small images, fonts, or SVG graphics into Base64 strings for inline HTML/CSS data:image/png;base64,... tags.
  • HTTP Header Transmission: Format basic HTTP authentication credentials (username:password) into Authorization: Basic <base64> headers.
  • URL Parameter Passing: Use the URL-safe mode to encode complex IDs, state tokens, or JSON objects into query parameters without reserved character clashes.
  • Payload Inspection: Decode incoming webhook payloads, JWT segments, and email MIME attachments to inspect their plain text contents.

Base64 Encoding Method, RFC 4648 & Worked Vectors

Base64 maps binary data into an ASCII subset of 64 characters: uppercase letters (A–Z), lowercase letters (a–z), digits (0–9), and two symbols (+ and /). Three 8-bit bytes (24 bits) are divided into four 6-bit values, increasing total payload length by exactly 33%.

RFC 4648 Standard Vector: "Man"

Canonical 3-byte test vector:

  • Plain Text: Man
  • ASCII bytes: 77, 97, 110
  • Binary (24 bits): 01001101 01100001 01101110
  • 6-bit chunks: 19, 22, 5, 46
  • Base64: TWFu

URL-Safe Substitution

Safe representation for URLs and filenames:

  • Standard: subjects?_d → c3ViamVjdHM/X2Q=
  • URL-Safe: + → -, / → _
  • Result: c3ViamVjdHM_X2Q=
  • Can be placed directly in query parameters without percent-encoding.

Multilingual UTF-8 Handling

Accents and emojis encoded losslessly:

  • Input: café 🚀
  • UTF-8 bytes: 9 bytes
  • Base64: Y2Fmw6kg8J+agA==
  • Decodes back to original characters without corruption.

Worked Examples

Encode ASCII Text 'Man' to Standard Base64

Mode: Encode to Base64 · Input: Man · URL-Safe: Disabled

  1. Convert ASCII characters to 8-bit bytes: 'M' (77), 'a' (97), 'n' (110)
  2. Concatenate into 24-bit binary stream: 01001101 01100001 01101110
  3. Split into four 6-bit index integers: 19, 22, 5, 46
  4. Map to Base64 index table: T, W, F, u

Result: TWFu

Encode URL-Safe Base64 with Symbols

Mode: Encode to Base64 · Input: subjects?_d=1 · URL-Safe: Enabled

  1. Convert characters to standard Base64 representation: c3ViamVjdHM/X2Q9MQ==
  2. Substitute standard '+' with '-' and '/' with '_'
  3. The resulting string is safe for inclusion in URLs and query parameters

Result: c3ViamVjdHM_X2Q9MQ==

Decode Base64 to Plain Text

Mode: Decode from Base64 · Input: SGVsbG8gV29ybGQh

  1. Map four-character chunks back to 6-bit numeric values
  2. Recombine 6-bit chunks into 8-bit UTF-8 byte sequences
  3. Decode UTF-8 bytes to unicode characters

Result: Hello World!

Common Mistakes to Avoid

  • Confusing Encoding with Encryption: Base64 is not a cipher. It contains no secret key, initialization vector, or computational hardness. Anyone can decode Base64 in milliseconds. For security, apply AES-GCM or ChaCha20 encryption before Base64 encoding.
  • Surrogate Pair Corruption with btoa(): The native JavaScript window.btoa() function assumes Latin-1 encoding (code points 0–255). Passing characters like emojis or accented vowels throws an uncaught DOMException. Proper implementations always encode strings to UTF-8 byte arrays first.
  • Unpadded String Truncation: Some web frameworks strip trailing = padding characters. A robust decoder must normalize padding length to a multiple of 4 before processing to prevent decoding errors.

Frequently Asked Questions

Is Base64 considered encryption?

No. Base64 is an encoding algorithm, not encryption. It provides zero security, confidential protection, or cryptographic secrecy. Anyone who receives a Base64 string can instantly decode it back to plain text without a key.

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

Standard Base64 (RFC 4648 §4) uses '+' and '/' in its 64-character alphabet, which require percent-encoding when placed inside URLs or filenames. URL-safe Base64 (RFC 4648 §5) substitutes '-' for '+' and '_' for '/', eliminating URL delimiter conflicts.

Does this encoder safely handle UTF-8 characters and emojis?

Yes. Standard browser btoa() fails on characters beyond the Latin-1 range. Our tool converts all text through native UTF-8 byte encoders, guaranteeing full fidelity for accented letters, Asian alphabets, and emojis (e.g. 🚀).

Is my text transmitted to any server?

No. All encoding and decoding runs 100% locally in your browser memory. We never transmit, log, or store any data.

Why does Base64 output end with '=' equal signs?

The '=' symbol is padding. Base64 processes data in 3-byte chunks (24 bits) into four 6-bit characters. If the input byte length is not divisible by 3, one or two '=' characters pad the final block.

Sources & References