πŸ”

Base64 Encoder/Decoder

Encode and decode text to/from Base64 format

Last updated

How to Use This Tool

Paste text to encode to Base64, or paste Base64 to decode back to readable text, then copy the result.

When Should You Use This Tool?

Use this when you need to safely move small text data through systems that don’t like special characters (not for security).

See also: Unit Converter, Coin Flip .

What does a Base64 encoder and decoder do?

A Base64 encoder turns data into a string built from 64 plain ASCII characters (A to Z, a to z, 0 to 9, plus + and /), so it can pass through systems that only handle text. A decoder reverses the process. This tool encodes any text you type or paste into Base64 or URL-safe Base64URL, and decodes either form back into readable text, all inside your browser.

You will meet Base64 in HTTP Basic Authentication headers, JSON Web Tokens (JWTs), data URLs, email attachments, Kubernetes secrets and many APIs that need to carry binary data inside JSON or XML.

How do I encode or decode Base64 with this tool?

  1. Pick Encode to Base64 or Decode from Base64 in the Operation menu.
  2. Paste your text, or the Base64 or Base64URL string you want to read, into the input box.
  3. When encoding, tick Encode as Base64URL if you need the URL-safe form used in JWTs and URLs.
  4. Click Process. The result appears below the buttons.
  5. Click Copy Result to copy the output to your clipboard.

If the input cannot be decoded, the tool shows a message below the buttons explaining why, and clears the previous result so you cannot copy stale output by mistake. Nothing you enter is sent to a server.

How does Base64 encoding work?

Base64 reads the input three bytes (24 bits) at a time, splits those bits into four groups of 6 bits, and maps each 6 bit value (0 to 63) to one character of the alphabet. The classic example is the word "Man":

Text:     M          a          n
Bytes:    77         97         110
Binary:   01001101   01100001   01101110
6-bit:    010011  010110  000101  101110
Index:    19      22      5       46
Base64:   T       W       F       u      => TWFu

When the input length is not a multiple of three, the encoder adds one or two = padding characters so the output length is always a multiple of four:

Input textBytesBase64 output
Man3TWFu
Ma2TWE=
M1TQ==
hello5aGVsbG8=
user:pass9dXNlcjpwYXNz

With Encode as Base64URL ticked, the tool writes - instead of +, _ instead of /, and leaves out the padding, so Ma becomes TWE and πŸ‘ becomes 8J-RjQ.

Why is Base64 output about 33% larger than the input?

Base64 output is about 33% larger because every 3 bytes of input become 4 characters of output, a ratio of 4 to 3. The exact length for n input bytes is 4 × ceil(n / 3) characters, so a 30 KB file becomes about 40 KB of Base64 text, and some encoders add line breaks on top of that. This overhead is the reason large images embedded as data URLs often make a page heavier, even though they save an HTTP request.

Is Base64 encryption?

No. Base64 is an encoding, not encryption, and it provides no security. There is no key, so anyone who sees a Base64 string can decode it instantly, including with this page. Take a typical HTTP header:

Authorization: Basic dXNlcjpwYXNz
Decoded:              user:pass

That is why Basic Authentication is only safe over HTTPS, and why a Base64 value in a config file or a JWT payload should never be treated as secret. If you need confidentiality, use real encryption such as AES. If you are storing passwords, use a password hashing function such as bcrypt or Argon2.

Does this tool handle Unicode, accents and emoji?

Yes. The browser's built-in btoa() function only accepts characters in the Latin-1 range and throws an error on anything else, so this tool converts your text to UTF-8 bytes first and then encodes those bytes. Decoding reverses both steps, so accented letters, non-Latin scripts and emoji survive a round trip:

cafΓ©  =>  Y2Fmw6k=
πŸ‘    =>  8J+RjQ==

Because the tool works on UTF-8, its output matches what you get from the base64 command on Linux and macOS, Buffer.from(text).toString('base64') in Node.js, and base64.b64encode(text.encode('utf-8')) in Python.

Why does Base64 decoding fail?

Before decoding, the tool removes spaces and line breaks, converts the Base64URL characters - and _ to + and /, and adds any missing = padding. So standard Base64, Base64URL and unpadded strings all decode without editing. When decoding still fails, the cause is normally one of these:

ProblemWhat it looks likeFix
Data URL prefixdata:image/png;base64,iVBOR...Remove everything up to and including the comma
Binary contentAn image, PDF or ZIP file encoded as Base64The tool says the data looks binary and shows the byte count; use a file decoder, as this tool only outputs text
Truncated stringPart of the string is missing, often from a partial copyCopy the whole string again; a length that is 1 more than a multiple of 4 can never be valid
Stray charactersQuotes, backslashes or \n copied from source codeKeep only A to Z, a to z, 0 to 9, +, /, -, _ and =

How do I read a JWT payload with this decoder?

A JWT has three Base64URL parts separated by dots: header, payload and signature. Copy the middle part, paste it in as it is, and decode it. The tool converts the URL-safe characters and adds the missing padding for you:

Input:  eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ
Output: {"sub":"1234567890","name":"John Doe","iat":1516239022}

The signature part is raw binary, so decoding it usually shows the binary data message instead of text. Decoding only shows you the claims. It does not verify the signature, so it tells you nothing about whether the token is genuine.

Frequently Asked Questions

Is Base64 encryption?
No, Base64 is encoding, not encryption. It uses no key, is fully reversible and provides no security: anyone can decode a Base64 string. Use real encryption such as AES when data must stay private.
Can I encode binary files?
No, this tool works with text only. It has no file upload, and if you decode Base64 that represents an image, PDF or other binary file, it tells you the data looks binary and cannot be shown as text, because the bytes are not valid UTF-8. Use a command line tool such as base64 on Linux or macOS for files.
Why is the encoded output longer?
Base64 turns every 3 bytes into 4 characters, so the output is about 33% larger than the input. Each character carries only 6 bits of data instead of the 8 bits in a full byte.
What if decoding fails?
Check that the input only contains A to Z, a to z, 0 to 9, + and / (or - and _ for Base64URL), with optional = padding. Remove any data URL prefix such as data:image/png;base64, and make sure you copied the whole string. Spaces, line breaks and missing padding are handled for you.
Can I encode special characters or emojis?
Yes. The tool converts your text to UTF-8 before encoding, so accented letters, non-Latin scripts and emoji are encoded correctly, and decoding restores the original characters.
What is the difference between Base64 and Base64URL?
Base64URL is a variant for URLs and filenames. It replaces + with - and / with _, and usually drops the = padding. JWTs use Base64URL. This tool decodes both forms automatically, and the Encode as Base64URL option produces the URL-safe form without padding.
Why does my Base64 string end with = or ==?
The equals signs are padding. They appear when the input length is not a multiple of 3 bytes: one = when there are 2 bytes left over, and == when there is 1 byte left over.
Is my data sent to a server?
No. Encoding and decoding run in JavaScript in your browser, so the text you paste is never uploaded. It is still good practice not to paste live passwords or tokens into any website.