Skip to content

Base64 Encoder — Encode Text or Files to Base64 Online

Free

Encode any text or file to Base64 instantly in your browser. Supports standard and URL-safe encoding. Free, no upload, no account.

encode to base64text to base64base64 encoder free
All Developer Tools

Settings guide

Encoding variants:

  • ·Standard Base64 — Uses + and / characters with = padding. Required for MIME email, most file encodings, and any context that does not pass the string through a URL.
  • ·URL-safe Base64 — Replaces + with - and / with _. Removes or makes optional the = padding. Required for JWT tokens, OAuth state parameters, and any encoded data passed in a URL query string or path segment.

Line wrapping:

  • ·No wrapping — Single-line output. Standard for API payloads, JSON values, and programmatic use.
  • ·76 characters (MIME) — Line breaks every 76 characters. Required by RFC 2045 for email attachments encoded in MIME format.

Format comparison

Base64 vs hex encoding: Both represent binary as ASCII text. Base64 produces ~33% overhead (3 bytes → 4 characters); hex produces ~100% overhead (1 byte → 2 characters). Base64 is the right choice when size matters. Hex is more readable for byte-by-byte inspection and is standard for hash outputs and cryptographic keys.

Base64 vs encryption: Base64 is encoding, not encryption. It is trivially reversible by anyone — atob() in any browser decodes it instantly. Never use Base64 to obscure sensitive data. It exists to safely transport binary data through text channels, not to protect it.

How it works

1

Input

Paste text or upload a binary file. Text is converted to its UTF-8 byte representation before encoding.

2

Group bytes

The byte sequence is divided into 3-byte groups. Each group of 24 bits is split into four 6-bit values.

3

Map to characters

Each 6-bit value (0–63) maps to one of 64 printable ASCII characters: A–Z, a–z, 0–9, + and /. Padding characters = are added when the input length is not a multiple of 3.

4

Copy the result

The encoded string is ready to paste into an HTTP header, JSON field, CSS data URI, or wherever it is needed. Select standard or URL-safe output based on the destination.

About this format

Base64 encoding converts binary data — and by extension, any text — into a string of 64 printable ASCII characters. The encoded string is safe to embed anywhere that only accepts text: HTTP headers, JSON values, CSS data URIs, HTML attributes, and email bodies.

Common encoding tasks: generating the `Authorization: Basic` header for HTTP authentication (Base64 of `username:password`), creating CSS data URIs for embedding small images without a separate HTTP request, encoding a file attachment for an email API, or embedding binary data in a JSON payload.

Enter text or upload a file — the Base64 output appears immediately.

Frequently asked questions

What is Base64 encoding used for?+
Base64 is used to safely transmit binary data through text-only channels. Common uses: HTTP Basic Authentication headers (Base64 of username:password), CSS data URIs for embedding images in stylesheets, JWT tokens (header and payload are Base64url-encoded), and email attachments in MIME format.
What is the difference between standard and URL-safe Base64?+
Standard Base64 uses + and / characters, which have special meaning in URLs. URL-safe Base64 replaces + with - and / with _ so the encoded string can be used in URLs, query strings, and JWT tokens without percent-encoding.
How much larger is Base64 output than the original input?+
Base64 encoded output is approximately 33% larger than the input. Every 3 bytes of input become 4 characters of Base64 output. A 100KB file encodes to approximately 133KB of Base64 text.
Is Base64 encoding the same as encryption?+
No. Base64 is encoding — a reversible transformation with no secret key. Any Base64 string can be decoded by anyone using atob() in a browser or base64 --decode in a terminal. Never use Base64 to protect sensitive data.
Can I encode a binary file (image, PDF) to Base64?+
Yes. Upload the file directly and the entire binary content is encoded to a Base64 string. This is how CSS data URIs work: background-image: url('data:image/png;base64,iVBOR...') embeds the encoded image directly in the stylesheet.

Related tools and guides