Data & Storage

Base64 Calculator

Free Base64 encoder and decoder. Change text to Base64 and back, with Unicode and emoji support, URL-safe Base64, and a copy button. Works in your browser.

Share:X
Loading calculator interface...

How the Base64 Calculator Works

Base64 is a way to write any data, such as text or a picture, with only 64 safe characters: the letters A to Z and a to z, the digits 0 to 9, and the signs + and /. It was made for places where only plain text can be sent, such as an email, a web address, a JSON file or an HTML page. The Base64 Encode / Decode tool changes text to Base64, and Base64 back to text.

Base64 is not encryption. It hides nothing. Anyone can decode it in a second, so never use it to protect a password or a secret.

The 64 characters

Each character stands for a number from 0 to 63. The alphabet has 64 characters (each block below is one of them), and the sign = is used at the end as padding.

████████████████████████████████████████████████████████████████
A-Z 0-25 (blue)   a-z 26-51 (green)   0-9 52-61 (amber)   + / 62-63 (red)

How the encoding works

  1. The text is changed to bytes (the tool uses UTF-8, so every letter and emoji has its bytes).
  2. The bytes are put together in groups of 3. Three bytes are 24 bits.
  3. The 24 bits are cut into 4 pieces of 6 bits. A piece of 6 bits is a number from 0 to 63.
  4. Each number is changed to its character in the alphabet.

Example, the text Man:

StepValue
LettersM, a, n
Bytes (numbers)77, 97, 110
Bits, 8 for each byte01001101 01100001 01101110
Bits, 6 for each group010011 010110 000101 101110
Numbers of the groups19, 22, 5, 46
CharactersTWFu

The chart shows the same 24 bits, as 3 bytes of 8 bits (first line) and as 4 groups of 6 bits (second line).

████████████████████████
████████████████████████

Padding

If the number of bytes cannot be divided by 3, the last group is short. The encoder fills it with zero bits, and adds one or two = signs, so that the result always has a length that can be divided by 4. One byte left over gives two = signs, and two bytes left over give one.

Examples

TextBytes in UTF-8Base64Characters
Man3TWFu4
Ma2TWE=4
M1TQ==4
Hello World11SGVsbG8gV29ybGQ=16
café5Y2Fmw6k=8
€34oKs4
你好65L2g5aW98
😀48J+YgA==8

Letters with accents, the euro sign, Chinese characters and emoji need 2, 3 or 4 bytes each in UTF-8. This tool handles them correctly. Many simple encoders do not, and they stop with an error when the text has a character outside of the basic Latin letters.

How much bigger does it get?

Every 3 bytes become 4 characters, so Base64 is about a third bigger (133%) than the data, plus the padding. The blue bar is the data, and the green bar is the Base64 (each block is 3 bytes and 4 characters).

3 bytes   █ 3
          █ 4 characters
6 bytes   ██ 6
          ██ 8 characters
12 bytes  ████ 12
          ████ 16 characters
30 bytes  ██████████ 30
          ██████████ 40 characters
60 bytes  ████████████████████ 60
          ████████████████████ 80 characters
120 bytes ████████████████████████████████████████ 120
          ████████████████████████████████████████ 160 characters

Decoding

Decoding is the same steps in the other direction: each character is changed to its number, the 6-bit pieces are put together, cut into bytes, and the bytes are read as UTF-8 text. The tool is forgiving:

  • Spaces and line breaks are ignored, so you can paste Base64 that is wrapped over several lines.
  • It accepts the standard form and the URL-safe form.
  • A missing padding is added.
  • If the bytes are not UTF-8 text (for example, they are a picture), the tool tells you, and shows one letter for each byte.

The URL-safe form

The signs + and / and the padding = have a special meaning in a web address. The URL-safe form of Base64 uses - instead of +, _ instead of /, and it usually leaves out the =. It is used in web tokens (JWT), links and file names. Choose it in the tool when you encode.

Where Base64 is used

  • Small pictures inside a web page or a style sheet (data URLs).
  • Attachments of an email.
  • The parts of a web token (JWT).
  • Sending binary data in a JSON file or a form.

What this tool does not include

  • Encoding or decoding of files. It works with text.
  • Encryption, or any kind of protection of the data.
  • Texts of more than 200,000 characters to encode, or 1,000,000 characters of Base64 to decode.

The conversion is made in your browser, and your text is not sent to a server. Do not use Base64 to hide sensitive information.

Frequently Asked Questions

Is the Base64 Calculator free to use?+

Yes. The Base64 Calculator, and every other tool on CalculatorBooth, is completely free to use with no sign-up or account required.

Is my data stored or shared?+

All computations are performed locally in your browser. No private inputs or parameters are stored or transmitted.

How accurate is this calculator?+

It's built and tested for accuracy, but the result is an estimate for planning purposes. It isn't a substitute for advice from a qualified financial, medical, or legal professional.

Related Calculators