All tools

Base64 encoder / decoder

Encode or decode UTF-8 text as Base64.

Base64 encoder / decoder
Action
InputTEXT

Press Command or Control plus Enter to run. Tab inserts indentation; press Escape, then Tab, to leave the editor.

Result
Your result will appear here.
Ready1 line · 15 chars

About the Base64 encoder / decoder

Base64 represents binary data or text using only 64 safe characters: A–Z, a–z, 0–9, + and /. It is used to put data where only plain text is allowed, such as email attachments, data URLs, HTTP Basic authentication headers and JSON fields.

This tool encodes text to Base64 and decodes Base64 back to text using UTF-8, so accented letters, non-Latin scripts and emoji survive the round trip correctly.

How to use the Base64 encoder / decoder

  1. Choose Encode or Decode in the Action menu.
  2. Paste your text or Base64 string into the Input editor.
  3. Click the action button or press Ctrl + Enter (Cmd + Enter on Mac).
  4. Click Copy result to copy the output.

Examples

Encode text, including non-ASCII characters

Input

Hello, wörld ✓

Output

SGVsbG8sIHfDtnJsZCDinJM=

Text is encoded as UTF-8 first, so accents and emoji work.

Build an HTTP Basic auth header

Input

admin:s3cret

Output

YWRtaW46czNjcmV0

Send it as Authorization: Basic YWRtaW46czNjcmV0. Base64 is encoding, not encryption, so only send it over HTTPS.

Common errors and how to fix them

Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.

The input has characters outside the Base64 alphabet, such as spaces or line breaks in the middle, or it is Base64URL (- and _ instead of + and /). Remove the extra characters, or swap - for + and _ for /.

Decoded text is garbled (é instead of é)

The data was decoded as Latin-1 instead of UTF-8. atob alone returns bytes as characters; decode them with new TextDecoder().decode(...), which is what this tool does.

InvalidCharacterError when calling btoa

btoa only accepts Latin-1 characters, so it fails on text like ✓. Encode to UTF-8 bytes first with TextEncoder, then Base64 the bytes.

Good to know

  • Base64 is an encoding, not encryption. Anyone can decode it, so it doesn't protect sensitive data.
  • Encoded output is about a third larger than the original.
  • Decoding expects standard Base64. URL-safe Base64, which uses - and _ instead of + and /, needs those characters swapped first.
  • Decoded data must be valid UTF-8 text; binary files such as images can't be shown as text.

Frequently asked questions

What do the = signs at the end mean?

They are padding. Base64 works in groups of 3 bytes, and one or two = characters fill the last group when the input length isn't a multiple of 3.

Why does decoding fail?

Usually because the input contains characters outside the Base64 alphabet, uses the URL-safe variant, has been cut off, or decodes to binary data rather than UTF-8 text.

Is Base64 the same as encryption?

No. Base64 only changes how data is written; it has no key and can be reversed by anyone. Use real encryption to protect secrets.