Skip to content
Developer

Base64 Encoder / Decoder

Encode text to Base64 or decode Base64 to text with UTF-8 support.

base64encodedecodeutf8
Loading tool…

About the Base64 Encoder / Decoder

The Base64 Encoder / Decoder converts plain text to Base64 and back with full UTF-8 support, which matters more than it sounds: JavaScript's built-in atob and btoa choke on emoji, accented letters, and most non-Latin scripts, while this tool encodes multi-byte characters correctly and decodes them without corruption. The Encode tab takes any text and produces standard Base64; the Decode tab reverses it and validates both the character alphabet and the padding, reporting errors like Invalid Base64 — length is not a multiple of 4 instead of guessing. A URL-safe variant switch swaps + and / for - and _, strips trailing padding on encode, and restores both on decode — the exact behavior you need when embedding tokens inside URLs or JWT-style payloads. A Use output as input button feeds the current result into the opposite tab, so you can instantly round-trip a value and confirm it survives encoding. Live stats show the mode plus input and output byte counts, and results download as encoded.b64 or decoded.txt. For decoding a base64 string from an email header, or encoding credentials for a test request, this is the fastest path.

Base64 Encoder / Decoder examples

Input
Hello, Fernandes Labs! 🚀
Output
SGVsbG8sIEZlcm5hbmRlcyBMYWJzISDwn5qA
Note: The default Encode tab input — UTF-8 text with an emoji encodes correctly, something plain btoa cannot do safely.
Input
SGVsbG8sIEZlcm5hbmRlcyBMYWJzISDwn4yN
Output
Hello, Fernandes Labs! 🌍
Note: The default Decode tab input — whitespace is stripped, the alphabet is validated, and the bytes decode back to text.
Input
user:pass?ref=100 (URL-safe variant on)
Output
dXNlcjpwYXNzP3JlZj0xMDA
Note: With the URL-safe switch on, padding is stripped and any + or / characters would become - and _ so the value sits safely inside a URL.

How to use the Base64 Encoder / Decoder

  1. 1

    Choose the Encode or Decode tab for the direction you need.

  2. 2

    Type or paste your text (or Base64 string) into the input textarea.

  3. 3

    Flip the URL-safe variant switch if the value must survive inside a URL or token.

  4. 4

    Press Use output as input to feed the current result into the opposite tab for a round-trip check.

  5. 5

    Copy the result or download it as encoded.b64 / decoded.txt from the result box.

Common use cases

  • Encoding credentials for an Authorization header in a quick API test.
  • Decoding a base64 string pasted from an email attachment or a JWT payload section.
  • Preparing URL-safe tokens for password-reset links that pass through email clients.
  • Embedding small encoded data as a data URI in HTML.
  • Decoding base64 log fragments from a mobile crash report.
  • Verifying that a round trip through your own encoder preserves UTF-8 characters exactly.

Best practices

  • Never treat Base64 as encryption — it is reversible encoding and offers zero confidentiality.
  • Decode JWT payload segments with URL-safe mode on, since segments almost always omit = padding.
  • Use the URL-safe variant whenever the string will travel through URLs, query strings, or path segments.
  • Remember that standard Base64 output is not whitespace-tolerant everywhere; the decoder here strips whitespace, but strict endpoints may not.
  • Test emoji and accented text when validating an encoder pipeline — ASCII-only tests hide UTF-8 bugs.
  • Read the decoder's specific errors (bad alphabet character, wrong length) instead of guessing why output is empty.

Tips

  • Keep the URL-safe switch on while decoding JWT payloads — they almost always omit padding.
  • Use Use output as input to prove your pipeline round-trips before trusting it in production code.
  • The Output bytes stat is a fast sanity check: decoded ASCII text should roughly match its character count in bytes.
  • If decoding produces garbled accents, the source was likely encoded from Latin-1, not UTF-8.

Frequently asked questions

btoa expects Latin-1 and throws on characters outside that range. This tool first encodes the text to UTF-8 bytes with TextEncoder, converts those bytes to a binary string, and only then applies btoa. Decoding reverses the process with TextDecoder, so multi-byte characters survive intact.

On encode, + becomes -, / becomes _, and trailing = padding is removed. On decode, - and _ are mapped back to + and /, and padding is restored until the length is a multiple of four, so unpadded JWT-style strings decode cleanly.

Standard Base64 encodes in groups of four characters. If the cleaned input length is not a multiple of four, the output is ambiguous and the decoder refuses rather than guessing. Adding the missing = padding or switching on URL-safe mode resolves it.

Yes — all whitespace is stripped before decoding, so pasting multi-line, wrapped Base64 blocks (common from email or certificates) works without manual cleanup.

Yes, encoding follows the standard alphabet A–Z, a–z, 0–9, + and / with = padding, matching RFC 4648 basic encoding. The URL-safe mode corresponds to the base64url alphabet from the same RFC.

The input is first checked against the alphabet and padding rules. A non-alphabet character triggers an Invalid Base64 error plus a toast, and the output stays empty until the input is corrected.

Explore more developer tools

Browse the full collection of developer tools on the hub, or jump back to all categories.

Related tools

Did this tool help?

Anonymous — one tap, no sign-up.