Developer

What Is Base64? How Encoding Works and Common Mistakes

ToolOrbit Engineering 2 min readUpdated
What Is Base64? How Encoding Works and Common Mistakes

Base64 is one of the most common encodings in modern software, yet it is widely misunderstood. It is not encryption and it is not compression. It is a way to represent arbitrary binary data using a 64-character alphabet of printable ASCII characters, so that data can travel safely through systems that were designed for text. This guide explains how it works and how to use the ToolOrbit Base64 Encode / Decode tool effectively.

What Base64 actually does

Base64 takes three bytes (24 bits) of input and splits them into four 6-bit groups. Each 6-bit group maps to one character from the set A-Z, a-z, 0-9, plus + and /. Because three input bytes become four output characters, Base64 increases data size by roughly 33%. When the input length is not a multiple of three, one or two = characters are added as padding.

  • Encoding text or binary into a transport-safe ASCII string
  • Embedding small images, fonts, or files directly in HTML or CSS via data URLs
  • Carrying binary payloads inside JSON, XML, or email (MIME)
  • Storing or transmitting credentials in HTTP Basic Authentication headers

Encoding and decoding Base64 step by step

Paste your text into the input box to encode it, or paste a Base64 string and switch to decode mode to recover the original. The tool is UTF-8 safe, so emoji and non-Latin scripts round-trip correctly rather than getting mangled. You can also drop a file to generate a data URL you can paste straight into a stylesheet or img tag.

Input:  Hello, ToolOrbit!
Base64: SGVsbG8sIFRvb2xPcmJpdCE=

Data URL: data:image/png;base64,iVBORw0KGgoAAAANS...
Tip: Base64 is encoding, not security. Anyone can decode it instantly. Never use Base64 to hide passwords, tokens, or secrets from prying eyes.

Common mistakes to avoid

  • Confusing standard Base64 (+ and /) with URL-safe Base64 (- and _) used in JWTs and query strings
  • Forgetting that naive btoa() in JavaScript breaks on Unicode unless you encode UTF-8 first
  • Embedding very large files as data URLs, which bloats your HTML and hurts caching
  • Trimming the trailing = padding and then expecting strict decoders to accept the result

Privacy and best practices

The ToolOrbit Base64 tool runs entirely in your browser. Your text and files are never uploaded to a server, which makes it safe for sensitive snippets like config fragments. Use Base64 when you need text-safe transport, prefer URL-safe variants inside URLs, and reach for real encryption whenever confidentiality actually matters.


Tools mentioned

More reading

View all guides
encodeURI vs encodeURIComponent: Which One to Use
Developer

encodeURI vs encodeURIComponent: Which One to Use

How percent-encoding works, the difference between encoding a whole URL and a single component, and the mistakes that break links.

2 min readUpdated
What Is a UUID? Version 4 vs Version 7 Explained
Developer

What Is a UUID? Version 4 vs Version 7 Explained

What a UUID looks like, why version 4 is the safe default, when version 7 is better, and best practices for IDs.

2 min readUpdated
How SHA-256 and SHA-512 Hashes Work: Hashing vs Encryption
Developer

How SHA-256 and SHA-512 Hashes Work: Hashing vs Encryption

What a hash function does, how to choose between SHA-256 and SHA-512, and why hashing is not encryption.

2 min readUpdated
What Is a JWT? Header, Payload and Signature Explained
Developer

What Is a JWT? Header, Payload and Signature Explained

A JSON Web Token has three parts. Learn what the header, payload and signature contain, how to read the claims, and why decoding is not verifying.

2 min readUpdated
What Is HTML Encoding? Entities & Escaping Explained
Developer

What Is HTML Encoding? Entities & Escaping Explained

Learn how HTML encoding works, why escaping prevents XSS and layout breaks, and how to encode and decode named, decimal, and hex entities.

2 min readUpdated
Unix Time Explained: Seconds, Milliseconds and Time Zones
Developer

Unix Time Explained: Seconds, Milliseconds and Time Zones

What a Unix timestamp is, how to tell seconds from milliseconds, how time zones come into it, and the values worth recognising.

2 min readUpdated
Binary, Octal, Decimal and Hex: How Number Bases Work
Developer

Binary, Octal, Decimal and Hex: How Number Bases Work

How positional number bases work, why very large values need exact arithmetic, and the hex and binary values you meet every day.

2 min readUpdated
Regex Basics: How Patterns, Flags and Character Classes Work
Developer

Regex Basics: How Patterns, Flags and Character Classes Work

How a regular expression is built, what the flags change, and the character classes you will use most.

2 min readUpdated