Base64EncodingDeveloper Tools

What is Base64 Encoding? Complete Guide with Examples

Understand Base64 encoding and decoding with real examples. Learn when to use Base64, how it works, and common use cases like embedding images in HTML.

ST
SmartToolsToday·March 28, 2026·6 min read
Ad · 728×90 Leaderboard

What is Base64?

Base64 is an encoding scheme that converts binary data into a text format using 64 printable ASCII characters: A-Z, a-z, 0-9, +, and /. It was designed to safely transmit binary data through systems that were designed to handle text, like email or URLs.

How Does Base64 Work?

Base64 takes 3 bytes (24 bits) of binary data at a time and converts them into 4 Base64 characters. Each Base64 character represents 6 bits of data. This means Base64-encoded data is roughly 33% larger than the original binary data.

Common Use Cases

  • Embedding images in HTML/CSS — Convert images to Base64 and embed them as data URLs: src="data:image/png;base64,..."
  • Email attachments — SMTP uses Base64 to encode binary attachments as text
  • API authentication — HTTP Basic Auth sends credentials as Base64-encoded strings
  • JWT tokens — JSON Web Tokens use Base64url encoding for their header and payload
  • Data URLs — Embedding small assets directly in HTML or CSS files

Base64 vs Encryption

It is important to understand that Base64 is NOT encryption. It is just an encoding — anyone can decode Base64 text instantly. Never use Base64 to "hide" sensitive information. Use proper encryption (like AES-256) for security.

Example

The text "Hello" in Base64 is SGVsbG8=. The = sign at the end is padding to make the length a multiple of 4.

Base64 URL Variant

The standard Base64 uses + and / which are unsafe in URLs. Base64url replaces these with - and _ and omits padding. This variant is used in JWT tokens and URL-safe contexts.

Try our free Base64 Encoder/Decoder to encode and decode Base64 strings instantly in your browser.

Ad · 728×90 Leaderboard