Skip to content

Base64 Encoder

Encode text to Base64 format online instantly. Free Base64 encoder for converting strings, data URIs, and binary content safely.

Encoding / Decoding
Instant results
Go to Decoder
0 characters

About Base64 Encoding

Base64 is a binary-to-text encoding scheme that converts binary data into a string of ASCII characters. It's commonly used for embedding images in HTML/CSS, sending data in URLs, or storing binary data in text-based formats.

URL Safe mode replaces + with -, / with _, and removes padding (=) for safe use in URLs.

How to Use Base64 Encoder

1

Enter your text

Type or paste the text you want to encode into the input field. Encoding happens automatically as you type — no submit button needed.

2

Choose Base64 variant (optional)

Standard Base64 uses '+' and '/' (default). For URL-safe contexts (JWT tokens, OAuth, URL parameters), select Base64URL which uses '-' and '_' instead.

3

View encoded output

The Base64-encoded string appears instantly in the output panel. The size is roughly 33% larger than your original text — the standard overhead of Base64 encoding.

4

Copy to use

Click Copy to put the encoded string on your clipboard. Use it in API payloads, CSS data URIs, JSON values, email attachments, or anywhere text-safe binary representation is needed.

When to Use Base64 Encoder

Embedding images in CSS data URIs

Small images (icons, gradients, decorative graphics under ~5KB) can be embedded directly in CSS using data: URIs (data:image/png;base64,...). This eliminates an HTTP request, improving load performance for above-the-fold critical CSS. Encode the image to Base64, wrap in 'data:image/{type};base64,', and paste into your CSS background-image property.

Sending binary in JSON or XML APIs

JSON and XML are text-only formats — binary data (file contents, encrypted payloads, certificates) must be Base64-encoded before inclusion. Common in: REST APIs accepting file uploads as JSON fields, configuration management transmitting certificates, mobile app sync protocols, and webhooks delivering binary payloads.

HTTP Basic Authentication credentials

Basic Auth encodes 'username:password' with Base64 in the Authorization header (Authorization: Basic dXNlcjpwYXNz). Although Base64 is not encryption, this format is standardized for compatibility — always use HTTPS when transmitting Basic Auth so the encoded credentials are protected by TLS, not by the encoding itself.

Email attachments (MIME encoding)

SMTP and other email protocols are text-only (7-bit ASCII originally). MIME (Multipurpose Internet Mail Extensions) wraps binary attachments in Base64 so they survive transmission through ancient email infrastructure. Most email clients handle this automatically, but understanding it helps when crafting emails programmatically or debugging delivery issues.

Base64 Encoder Examples

Encoding plain text

Input
Hello, World!
Output
SGVsbG8sIFdvcmxkIQ==

The 13-character string 'Hello, World!' becomes 20 characters of Base64 (with '==' padding to make the length divisible by 4). The 33% size increase is typical. The output uses only A-Z, a-z, 0-9, '+', '/', and '=' — all safe ASCII characters that survive transmission through any text protocol.

Encoding for URL inclusion (Base64URL)

Input
auth?token=Hello+World/Test==
Output
YXV0aD90b2tlbj1IZWxsbytXb3JsZC9UZXN0PT0

Base64URL replaces '+' with '-' and '/' with '_', and omits the '=' padding. Useful when the encoded value goes into a URL — standard Base64's '+' would be interpreted as a space, '/' as a path separator, and '=' often gets URL-encoded to %3D. Base64URL is the format used in JWT tokens.

Encoding HTTP Basic Auth credentials

Input
admin:supersecret
Output
YWRtaW46c3VwZXJzZWNyZXQ=

For HTTP Basic Auth, encode 'username:password' (with the colon literal) as Base64. The result goes in the Authorization header: 'Authorization: Basic YWRtaW46c3VwZXJzZWNyZXQ='. Anyone reading the header can decode it instantly — Base64 provides zero security. Always use HTTPS for Basic Auth to protect credentials with TLS encryption.

Tips & Best Practices for Base64 Encoder

  • 1.Don't use Base64 for security. It's an encoding, not encryption. Anyone can decode Base64 in 1 second with a browser DevTools console (atob('...')). For confidentiality, encrypt first with AES or similar, then Base64-encode the ciphertext if you need text-safe output.
  • 2.Compress before encoding for large data. gzip + Base64 is much smaller than raw Base64 (often 50-70% reduction). Use this pattern for embedding compressed assets, large config blobs, or any data >10KB where size matters.
  • 3.Use Base64URL for URL contexts (query params, fragment, path components). Standard Base64's '+', '/', and '=' need URL-encoding (%2B, %2F, %3D), making URLs longer and less readable. Base64URL is supported by JWT, modern web standards, and most languages' libraries.
  • 4.Don't Base64-encode text just because. JSON, HTML, and XML have their own escape mechanisms (\n in JSON strings, < in HTML, etc.) that are more efficient than Base64. Reserve Base64 for actual binary or for cases where existing escape mechanisms aren't sufficient.
  • 5.When debugging Base64 issues, check for whitespace and line breaks. Some implementations split Base64 into 76-character lines (MIME standard); others output a single long line. Decoders should handle both, but some strict parsers require specific line break formatting.
  • 6.For database storage of binary data, prefer native binary types (PostgreSQL bytea, MySQL BLOB) over Base64-encoded text — binary types use less space and avoid encoding/decoding overhead. Use Base64 only when you must store binary in text-only fields (e.g., legacy systems, certain logging frameworks).

Frequently Asked Questions

Base64 is a binary-to-text encoding scheme that represents binary data as a string of 64 ASCII characters (A-Z, a-z, 0-9, +, /). It enables safe transmission of binary data through text-based protocols (email, JSON, URLs, HTML) where some bytes might be misinterpreted. The padding character '=' fills the output to a multiple of 4 characters.