What Is Base64 Encoding? How It Works and When to Use It

Base64 shows up everywhere in web and app development: in email attachments, data URIs, API payloads, JWT tokens and configuration files. It looks like random text – SGVsbG8= – but it is simply a way to write any data using only safe text characters.

Free tool
Encode or decode Base64
Encode text to Base64 or decode it back with full UTF-8 support, use URL-safe Base64, and turn files or images into data URIs. Free – nothing uploaded.
Open Base64 Encoder / Decoder →

Why Base64 exists

Many systems were designed for text, not binary data. Email, JSON, URLs and HTML attributes can break if you put raw bytes into them. Base64 converts any data into 64 safe characters: A–Z, a–z, 0–9, + and / (plus = for padding).

How it works

  • Take the data 3 bytes (24 bits) at a time.
  • Split them into four groups of 6 bits.
  • Map each 6-bit value (0–63) to one of the 64 characters.
  • If the last group is incomplete, add = padding.

Example: the text Hi! becomes SGkh.

Because every 3 bytes become 4 characters, Base64 is about 33% larger than the original.

Common uses

UseExample
Data URIsSmall images embedded in HTML or CSS: data:image/png;base64,...
Email attachmentsMIME encodes attachments in Base64
APIs and JSONSending files or binary data inside JSON
TokensJWTs use Base64URL for their header and payload – try our JWT Decoder
Basic authenticationHTTP Basic auth encodes username:password (always use HTTPS)

URL-safe Base64

Standard Base64 uses + and /, which have special meaning in URLs. Base64URL replaces them with - and _ and often removes the = padding. Use it for anything that goes into a URL or file name. For normal URL parameters, see our URL Encoder / Decoder.

Base64 is not encryption

Anyone can decode Base64 instantly. Never use it to hide passwords, keys or personal data. For integrity checks use a hash (Hash Generator); for secrecy use real encryption.

Should you inline images as Base64?

  • Good for: tiny icons and images in emails or single-file pages.
  • Bad for: large images on websites – they become 33% bigger, cannot be cached separately and delay page rendering.

Unicode text

Older Base64 functions in JavaScript (btoa) fail with emoji or non-Latin text. Encode the text as UTF-8 first. Our Base64 Encoder handles UTF-8 automatically, including emoji, Hindi and Chinese.

FAQ

Is Base64 encryption?

No. It is an encoding anyone can reverse.

Why does Base64 end with = signs?

Padding fills the last group when the data length is not a multiple of 3 bytes.

How much larger is Base64?

About 33% larger than the original data.

What is the difference between Base64 and Base64URL?

Base64URL uses – and _ instead of + and / so the result is safe in URLs.

Is my data uploaded?

No. Encoding and decoding run in your browser.

Free tool
Try the free Base64 Encoder / Decoder
No signup and nothing uploaded – it runs right in your browser. Browse all 74 free tools on our Free Tools page.
Open Base64 Encoder / Decoder →

Need a website or app for your business? Talk to Techpass Master – we design and build websites and apps for clients worldwide.

WhatsApp us📞 Call now