TThe TextSolutions
Developer Tools·5 min read·June 9, 2026

What Is Base64 Encoding? How to Encode and Decode Online

Understand what Base64 encoding is, why developers use it, and how to encode or decode Base64 strings instantly in your browser. Covers URL-safe Base64 and common use cases.

Free Online Tool

Base64 Encoder/Decoder

Try it Free →

Base64 is one of those things developers encounter constantly but rarely stop to fully understand. You've seen it in email headers, image data URLs, API credentials, and JWT tokens. It looks like random gibberish — SGVsbG8sIFdvcmxkIQ== — but it follows a precise system. Here's what it is, why it exists, and how to encode or decode it instantly online.

What Is Base64?

Base64 is an encoding scheme that converts binary data into a string of 64 printable ASCII characters. Those characters are: A–Z, a–z, 0–9, +, and / (plus = for padding).

The name comes from the character set: 64 possible characters, each representing 6 bits of binary data. Three bytes (24 bits) of input always produce exactly four Base64 characters.

Important: Base64 is encoding, not encryption. It does not protect data — anyone can decode it instantly. Its purpose is to make binary data safe to transmit in text-based contexts.

Why Does Base64 Exist?

Many older protocols — email (SMTP), HTTP headers, XML, and HTML — were designed to carry text, not arbitrary binary data. Sending raw binary through these channels causes problems: control characters get interpreted as commands, and different systems handle line endings differently.

Base64 solves this by converting binary into a predictable set of safe text characters that travel through any text-based system without corruption.

Common Uses

Email attachments — MIME (the standard for email attachments) uses Base64 to encode file attachments so they can be sent as text over SMTP.

Data URLs — You can embed images directly in HTML or CSS without a separate file: <img src="data:image/png;base64,iVBORw0KGgo...">. This reduces HTTP requests at the cost of a larger HTML file.

API credentials — HTTP Basic Authentication sends credentials as username:password encoded in Base64: Authorization: Basic dXNlcjpwYXNz. Again, this is not encryption — the credentials are trivially decoded.

JWT tokens — JSON Web Tokens consist of three Base64-encoded sections (header, payload, signature) joined by dots. The payload is plain JSON that anyone can read — only the signature is cryptographically verified.

Storing binary in JSON or databases — JSON cannot contain raw binary. Base64 lets you embed images, PDFs, or other binary data inside a JSON field.

URL-Safe Base64

Standard Base64 uses + and /, which have special meanings in URLs (+ means space, / separates path segments). URL-safe Base64 replaces these with - and _, making the encoded string safe to include in query parameters and paths without percent-encoding.

When working with web APIs and tokens, check the documentation — some systems require URL-safe Base64.

How to Encode and Decode Online

  1. Select a mode — Choose "Encode" to convert text to Base64, or "Decode" to convert Base64 back to text.
  2. Paste your input — For encoding, paste plain text. For decoding, paste a Base64 string.
  3. Toggle URL-safe — Enable this if the Base64 you're working with uses - and _ instead of + and /.
  4. Copy the result — Click the copy button to grab the output.

Decoding a JWT Token

JWT tokens are a great example of Base64 in practice. A JWT looks like this:

eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyMTIzIn0.abc123

The three sections (split by .) are Base64-encoded. Decode the first two and you'll see the header and payload as plain JSON — our JWT decoder guide walks through this in detail. The third section is the cryptographic signature — decoding it shows binary, not readable text.

Tips

  • The == at the end is Base64 padding. Because every 3 bytes becomes 4 characters, if the input isn't divisible by 3, = characters pad the output to a multiple of 4. Some systems omit the padding.
  • Line length — RFC 2045 (email MIME) wraps Base64 at 76 characters per line. If you're decoding something with line breaks, you may need to remove them first.
  • Not compression — Base64 makes data larger, not smaller. Encoded data is about 33% bigger than the original.

Frequently Asked Questions

Is Base64 the same as encryption? No. Base64 is reversible with no key — it's just a different representation of the same data. Do not use it to "secure" sensitive information.

Why does Base64 end with ==? Padding. The encoder needs the output length to be a multiple of 4. If the input has 1 remaining byte, it adds ==; if 2 remaining bytes, it adds =.

Can I Base64-encode an image file? Yes — but you need to encode the raw binary file bytes, not text. Most programming languages have built-in functions for this (btoa() in browsers works on binary strings; Buffer.from(file).toString('base64') in Node.js).

What's the difference between ASCII and Base64? ASCII is a character encoding that maps numbers to characters. Base64 is an encoding that represents binary data using ASCII characters. They're different things that work together.

Related Guides

Ready to try it?

Base64 Encoder/Decoder — Free & Browser-Based

Open Base64 Encoder/Decoder