What is Base64 Encoding?

Base64 is everywhere in web development — in JWTs, data URLs, API authentication, and email attachments. But what exactly is it, why do we need it, and how do you use it?

Free Online Base64 Encoder / Decoder

Encode or decode Base64 strings instantly. Supports text and files. Runs entirely in your browser.

Open Base64 Encoder / Decoder →

What is Base64?

Base64 is an encoding scheme that converts binary data into a string of ASCII characters. It uses a set of 64 characters — A-Z, a-z, 0-9, +, and / — to represent any sequence of bytes.

The name "Base64" refers to the 64 characters used in the encoding. Each Base64 character represents 6 bits of data, so 3 bytes (24 bits) of input become 4 Base64 characters (24 bits).

Example
Original text:  Hello, World!
Base64 encoded: SGVsbG8sIFdvcmxkIQ==

Why is Base64 used?

Binary data can contain bytes that have special meaning in certain contexts — for example, null bytes or line breaks that would break an email protocol or a URL. Base64 solves this by converting any binary data into safe, printable ASCII characters that can be transmitted through any text-based system.

Common use cases:

Note: Base64 is encoding, not encryption. Anyone can decode a Base64 string — it provides no security. Never use Base64 to hide sensitive data.

Base64 vs Base64URL

Standard Base64 uses + and / characters, which have special meaning in URLs. Base64URL is a URL-safe variant that replaces + with - and / with _. JWTs use Base64URL encoding.

VariantCharacters usedPaddingUse case
Base64A-Z, a-z, 0-9, +, /= paddingGeneral encoding, email
Base64URLA-Z, a-z, 0-9, -, _No paddingJWTs, URLs, filenames

How to encode and decode Base64 online

  1. Open the Base64 encoder/decoder on tinybench.dev
  2. Choose Encode or Decode mode
  3. Paste your text or upload a file
  4. Copy the result — all in your browser, nothing sent to a server

Base64 in code

JavaScript — browser
// Encode
const encoded = btoa('Hello, World!');  // "SGVsbG8sIFdvcmxkIQ=="

// Decode
const decoded = atob('SGVsbG8sIFdvcmxkIQ==');  // "Hello, World!"
Python
import base64

# Encode
encoded = base64.b64encode(b'Hello, World!').decode('utf-8')

# Decode
decoded = base64.b64decode('SGVsbG8sIFdvcmxkIQ==').decode('utf-8')
Node.js
// Encode
const encoded = Buffer.from('Hello, World!').toString('base64');

// Decode
const decoded = Buffer.from('SGVsbG8sIFdvcmxkIQ==', 'base64').toString('utf-8');

Frequently asked questions

Does Base64 increase file size?
Yes. Base64 encoding increases the size of data by approximately 33%. For every 3 bytes of input, you get 4 bytes of Base64 output. This is a trade-off for compatibility with text-based systems.
What is the = padding at the end?
Base64 encodes 3 bytes at a time. If the input length isn't a multiple of 3, = padding characters are added to make the output length a multiple of 4. One = means 2 bytes remained; == means 1 byte remained.
Is Base64 the same as encryption?
No. Base64 is a reversible encoding anyone can decode without a key. Encryption scrambles data so only someone with the correct key can read it. Never use Base64 as a security measure.
Can I use Base64 for images in HTML?
Yes — using data URLs: <img src="data:image/png;base64,iVBOR...">. This embeds the image directly in HTML, eliminating an HTTP request. The trade-off is a larger HTML file and no browser caching of the image separately.

Try it now — free & private

Runs entirely in your browser. No sign-up, no uploads, no tracking.

Open Base64 Encoder / Decoder →

Related tools on tinybench.dev