Skip to main content
VVertex Solutions
All toolsPDF ToolsImage ToolsText ToolsCalculatorsDeveloperBlog
VVertex Solutions

Browse tools for merging and compressing PDFs, resizing and converting images, formatting text and JSON, running calculators, and working with code.

Popular Tools

  • Mortgage Calculator
  • GPA Calculator
  • Tip Calculator
  • BMI Calculator
  • Percentage Calculator
  • EMI Calculator
  • Merge PDF
  • JSON Formatter

Categories

  • All tools
  • PDF Tools
  • Image Tools
  • Text Tools
  • Calculators
  • Developer Tools

Company

  • About
  • About the Author
  • Editorial Standards
  • How We Verify Tools
  • How Data Is Processed
  • Calculator Comparisons
  • Disclaimer
  • Privacy Policy
  • Cookie Policy
  • FAQ
  • Accessibility
  • Changelog
  • Terms of Service
  • Contact
  • Blog
  • RSS Feed

© 2026 Vertex Solutions. All rights reserved.

Free tools. No signup. Privacy first.

  1. Home
  2. Blog
  3. Understanding Base64 Encoding, in Plain English for Developers
Developerinformational7 min readPublished 2026-04-13 · Last updated 2026-10-23

Understanding Base64 Encoding, in Plain English for Developers

Base64 turns bytes into text. It uses 64 characters, pads with equals signs, and makes files larger. It does not encrypt or compress them.

By Rehan Baqir

Learn more

  • Base64 encode
  • Base64 decode

Quick answer

Base64 is reversible encoding with no key. Anyone can decode it, so it is not encryption. Use hashing and TLS for secrets. The encoding exists so arbitrary bytes can travel as 64 ASCII characters. Every 3 input bytes become 4 characters, so the text is about 33% larger than the binary.

Base64 translates arbitrary bytes into 64 ASCII characters so binary can sit inside JSON, email MIME headers, and data URLs without getting corrupted. Encryption, compression, and integrity checks are separate jobs. Anyone can reverse Base64, because there is no key. Every 3 input bytes become 4 characters, so the text is about 33% larger than the binary. Try a sample in the Base64 encoder and the Base64 decoder. Secrets need TLS and a real hash. The hash generator is the on-site tool for that fingerprint. Percent-escaping a URL is a different job, handled by the URL encoder. When the decoded payload is JSON, the JSON formatter makes a clipped string easier to spot.

Developers still find codebases where an API token or a password was "hidden" with Base64. Anyone can paste that string into a decoder and read it.

The problem Base64 solves

Computers store two broad kinds of data: text and binary. Text fits in JSON, XML, email bodies, and log files. Binary, such as image bytes, PDF chunks, and compressed archives, does not always fit cleanly.

Binary data can include null bytes, control characters, and sequences that break parsers. Email systems from the 1990s needed a way to attach photos without corrupting the message. Base64 was the answer: translate every chunk of binary into printable ASCII that survives a text-only channel.

It is binary written in an alphabet those systems already accept.

How the encoding works

Base64 reads input in groups of 3 bytes (24 bits) and splits those 24 bits into 4 groups of 6 bits. Each 6-bit value maps to one character from a 64-character alphabet:

A–Z  →  0–25
a–z  →  26–51
0–9  →  52–61
+    →  62
/    →  63

The name comes from those 64 printable characters.

Example: encoding the string Hi.

  1. H is 72 and i is 105 in ASCII
  2. Two bytes are 16 bits. Base64 pads the group out to 3 bytes with a zero byte
  3. Those 24 bits become four 6-bit indices
  4. The output is SGk=. The = is padding, covered below

You do not need to do this by hand. The point of the walkthrough is that Base64 is deterministic math. The same input produces the same output every time.

Use Base64 Encode to paste a small sample and watch the output change when you edit one character.

Padding with equals signs

The input length has to be divisible by 3 bytes. When it is not, the encoder adds padding:

| Input bytes mod 3 | Padding added | |-------------------|---------------| | 0 | none | | 1 | == | | 2 | = |

Decoders expect that padding. Strip it carelessly and some strict parsers fail. If you copied Base64 from a log and the trailing = was cut off, restore padding until the string length is a multiple of 4.

Base64 Decode is how you check whether a payload survived copy-paste.

Why the output is longer

Three raw bytes (24 bits) become four characters. That is a 4/3 ratio, about 33% larger than the original binary.

Base64 will not shrink a file. Compression is a different job. How PDF compression works removes redundant image data. Base64 adds characters so a text system can carry binary.

Encoding and encryption are different jobs

  • Encoding converts the format. It is reversible by design. No key is required
  • Encryption requires a secret key. The point is to block unauthorized reading
  • Hashing is a one-way fingerprint. See the Hash Generator

JWT payloads are Base64-encoded JSON. Anyone can decode the middle segment and read the claims. The signature, the third segment, provides integrity. It does not keep the payload secret.

For passwords, read Password Security Guide. Encoding a password before a POST, even over HTTPS, still sends recoverable text to anyone who intercepts the request and decodes it.

Text in Base64: the UTF-8 step

Encoding a string such as café needs a step people skip:

  1. Encode the string as UTF-8 bytes, not as ASCII code units alone
  2. Base64 those bytes

Decoding reverses the path: Base64, then bytes, then a UTF-8 string.

Skip UTF-8 and emoji, accented characters, and CJK text come out wrong. Test with non-English samples whenever you build a feature that handles more than English.

Base64url

Standard Base64 uses + and /, which already mean something in URLs. Base64url swaps them:

  • + becomes -
  • / becomes _
  • The padding = is often omitted

You will see Base64url in JWTs, in some API tokens, and in filename-safe encodings. A decoder may need the padding restored before it can process the string.

This is different from URL encoding, which percent-escapes individual characters (%20 for a space). Base64url is still an alphabet swap.

When Base64 makes sense

Good fits:

  • A tiny icon embedded in HTML or CSS as a data URL
  • Binary inside JSON when the API contract requires a text-only body
  • Email MIME attachments in older systems
  • A small binary blob in a database that prefers text columns

Poor fits:

  • A large file transfer. Use a multipart upload or a signed object-storage URL
  • "Protecting" credentials or other personal data
  • A stand-in for a real file-attachment endpoint in a modern REST API

Base64 in web development covers data URLs, API payloads, and the mistakes that show up in that setting.

Debugging malformed Base64

| Symptom | Likely cause | |---------|--------------| | Decode throws "invalid character" | Smart quotes, line breaks in a PEM block, or a Base64url string fed to a standard decoder | | Wrong output bytes | Decoded as Latin-1 instead of UTF-8 | | Truncated string | A chat tool or an email client clipped a long line | | Padding error | A missing trailing = |

Pipe decoded JSON through JSON Formatter when the payload nests structured data. Truncation is easier to see there than in raw bytes.

Base64 in the wild

You will run into Base64 when:

  • An API returns "content": "JVBERi0xLjQK..." for an inline PDF
  • DevTools shows data:image/png;base64,iVBORw0KG...
  • An OAuth flow passes a state parameter
  • A certificate file uses PEM, Base64 between header lines

The pattern is an alphanumeric block with an optional = at the end. Recognizing it speeds up debugging.

Security notes for production

  • Cap the input length. Decoding an attacker-controlled multi-megabyte string can exhaust memory
  • Validate before you decode. Reject characters outside the alphabet early
  • SVG inside a data URL can carry script if sanitization fails. Treat it as active content
  • Do not log decoded secrets. Decoding makes the bytes readable, including a password someone encoded by mistake

Limitations

The size overhead is about 33%. Encoding a 15 MB PDF or video into a Base64 JSON field balloons the payload to about 20 MB and spikes parser memory. Use a binary multipart upload or a signed upload URL for large files.

Base64 offers no confidentiality. Pair transport with TLS, and use encryption or hashing (Hash Generator) when you are protecting a secret.

Related articles

  • Base64 in Web Development: practical web use and the pitfalls
  • Common JSON Formatting Errors: when a Base64 field breaks a parser
  • Password Security Guide: what actually protects a credential

Conclusion

Base64 is a translation layer. Binary goes in, ASCII text comes out, larger and portable. Confidentiality, smaller files, and proof that the data is authentic come from other tools. Remember 3 bytes to 4 characters, and encode text as UTF-8 first. The odd strings in a log are usually payloads you can decode.

Related Tools

Free browser-based tools referenced in this article.

Base64 Encode
Base64 encode for UTF-8 text. Decoding is a separate page.
Base64 Decode
Base64 decode from a Base64 string back to UTF-8 text. Encoding is a separate page.
New
Hash Generator
Hash generator for MD5, SHA-1, SHA-256, and SHA-512 hex digests. Input stays in the page.
URL Encoder
URL encoder using encodeURIComponent for query values. Decoding is a separate page.
Featured
JSON Formatter
JSON formatter to pretty-print or minify JSON. Use JSON Validator when you only need the error.

Key takeaways

  • Base64 is a reversible binary-to-text encoding, not encryption. Anyone can decode it without a key.
  • Every 3 bytes of input become 4 ASCII characters (`A-Z`, `a-z`, `0-9`, `+`, `/`), increasing payload size by roughly 33%.
  • Encode non-ASCII strings as UTF-8 bytes before Base64 encoding, and use Base64url (`-` and `_`) inside URLs and JWTs.

Frequently Asked Questions

Common questions answered to help you get the most from this tool.

No. Base64 is encoding, a reversible format change. Anyone can decode it without a key. Use TLS and proper authentication for secrets. Encoding will not protect them.

Every 3 bytes of input become 4 ASCII characters, roughly a 33% size increase. You are trading compact binary for text-safe transport.

Uppercase A-Z, lowercase a-z, digits 0-9, plus sign (+), and slash (/). Padding uses equals signs (=) at the end when needed.

Yes. Any language runtime and most developer tools can decode Base64. Vertex Solutions offers free encode and decode tools for quick checks.

Base64url replaces + with - and / with _ so encoded strings survive in URLs and JWTs without extra escaping. Padding is often stripped.

About the author

Rehan Baqir is the founder & editor of Vertex Solutions. He builds browser-based tools and writes guides about PDF workflows, calculators, image tools, and developer utilities. Article pages show their publication and update dates when available. Read the editorial standards and tool-testing method for the site's stated approach to content and verification.

More about Rehan Baqir →

base64encodingbinarydeveloperfundamentals
Back to all articles

On this page

  • The problem Base64 solves
  • How the encoding works
  • Padding with equals signs
  • Why the output is longer
  • Encoding and encryption are different jobs
  • Text in Base64: the UTF-8 step
  • Base64url
  • When Base64 makes sense
  • Debugging malformed Base64
  • Base64 in the wild
  • Security notes for production
  • Limitations
  • Related articles
  • Conclusion

Related Articles

  • PHP security vulnerabilities: 10 flaws attackers exploit, and how to fix each one
  • UUID v4 vs v7: Sortable IDs in New Projects
  • URL Encoding and Decoding: A Developer Guide