JSONToonPro
Encoding tool

Base64 Encode

Free online Base64 encoder. Convert text, strings, and ASCII to Base64 format instantly. Supports Unicode and special characters. Everything runs client-side.

100% client sideInstant resultNo data sent
Text Input
0 chars
Base64 Output
Result appears here...

How Base64 Encoding Works

Base64 solves a very specific problem: moving arbitrary bytes through a channel that only accepts printable text. The trick is to stop thinking in bytes and start thinking in 6 bit chunks. Twenty-four bits divide evenly by both 8 and 6, so the encoder reads the input three bytes at a time (24 bits), slices that block into four groups of 6 bits, and turns each group into one character from a fixed 64 character alphabet.

Because three input bytes always become four output characters, the result is exactly four thirds the original size, an increase of roughly 33 percent before padding and line breaks are counted. That overhead is the price of safe transport, and it is why you should encode only when the destination genuinely cannot carry raw bytes.

  1. Read the next three bytes of input, giving 24 bits.
  2. Split those 24 bits into four groups of 6 bits each.
  3. Read each 6 bit group as a number from 0 to 63.
  4. Look up that number in the Base64 alphabet to get one character.
  5. Repeat until the input runs out, then apply the padding rules.

Worked Example: Encoding "Man"

The word Man is three ASCII characters, so it forms exactly one complete 24 bit block with nothing left over. That makes it the cleanest possible demonstration.

Input: M a n
ASCII: 77 97 110
Bits: 01001101 01100001 01101110
 
Joined: 010011010110000101101110
Regrouped: 010011 010110 000101 101110
Values: 19 22 5 46
Alphabet: T W F u
 
Output: TWFu

Result: Man encodes to TWFu, three bytes in, four characters out, no padding needed.

Padding Rules Explained

Real input rarely has a length that is a multiple of three. When the final block is short, the encoder pads the remaining bits with zeros, emits the characters it can, and then appends equals signs so the output length stays a multiple of four. Decoders use that count to work out how many bytes to throw away.

Man (3 bytes) -> TWFu no padding
Ma (2 bytes) -> TWE= one = means the last group carried 2 bytes
M (1 byte) -> TQ== two = means the last group carried 1 byte

You will never see three equals signs in valid Base64, because a leftover of three bytes is simply a full block. A single stray equals sign in the middle of a string is a reliable sign that two encoded values were concatenated by mistake.

Where Base64 Encoding Is Used

  • Data URIs. Small icons and fonts embedded directly in CSS or HTML as data:image/png;base64,... so the browser makes no extra request.
  • Email attachments. MIME uses Base64 because SMTP was designed for 7 bit text and would corrupt raw binary.
  • JWT segments. The header and payload of every JSON Web Token are Base64URL encoded JSON.
  • Binary fields in JSON and XML. Neither format can hold raw bytes, so image blobs and signatures travel as Base64 strings.
  • PEM certificates and keys. The text between the BEGIN and END markers is Base64 encoded DER.
  • HTTP Basic Authentication. The username and password pair is Base64 encoded, which is exactly why the scheme requires HTTPS.

Base64 Is Encoding, Not Encryption

Base64 provides zero confidentialityAnyone who sees a Base64 string can decode it in one second with no key, no password, and no special tooling. It is a reversible public transformation, the same as writing a number in hexadecimal. Never use it to hide passwords, API keys, tokens, or personal data. If the content must stay secret, encrypt it with a real algorithm and a real key, then Base64 the ciphertext if you also need safe transport.

The related confusion is with hashing. A hash such as SHA-256 is one way and cannot be reversed, while Base64 is fully reversible by design. Choosing the wrong one is one of the most common security mistakes in application code.

The Base64 Alphabet

Every 6 bit group produces a value between 0 and 63, and that value is looked up in the table below. RFC 4648 fixes this ordering: uppercase letters first, then lowercase, then digits, then the plus and slash characters. The padding character (=) is not part of the alphabet, it only marks the end of an incomplete group.

IndexChar
0A
1B
2C
3D
4E
5F
6G
7H
8I
9J
10K
11L
12M
13N
14O
15P
IndexChar
16Q
17R
18S
19T
20U
21V
22W
23X
24Y
25Z
26a
27b
28c
29d
30e
31f
IndexChar
32g
33h
34i
35j
36k
37l
38m
39n
40o
41p
42q
43r
44s
45t
46u
47v
IndexChar
48w
49x
50y
51z
520
531
542
553
564
575
586
597
608
619
62+
63/

Working on something related? Browse every free developer tool on the site, including a Base64 decoder, JSON to Base64, URL encoder, and hash generators. Everything runs entirely in your browser, so nothing you paste is ever uploaded.

Frequently asked questions

4 answers
Base64 is a binary-to-text encoding scheme that represents binary data using 64 printable ASCII characters (A-Z, a-z, 0-9, +, /). It converts every 3 bytes of input into 4 characters of output, making binary data safe to transmit in text-only contexts such as email bodies, HTTP headers, and JSON payloads.

More JSON Tools

About Base64 Encoding

Base64 encoding was designed to allow binary data to travel through systems that only handle plain text. The RFC 4648 standard defines the canonical Base64 alphabet and padding rules. Each group of 6 bits from the input is mapped to one of 64 printable characters. This tool encodes your input as UTF-8 bytes first, so any Unicode text including emoji and non-Latin scripts encodes correctly. The output is standard Base64 compatible with atob() in browsers, the base64 module in Python, and any compliant library.