Free Base64 Encoder & Decoder

Encode text and files to Base64 or decode Base64 strings back to readable text instantly with our free online tool

Samples:

You might also like

View All 136 Tools

Base64 Encoder & Decoder - Free Online Tool

Encode plain text or binary files to Base64, or decode Base64 strings back to readable content — instantly, in your browser. Supports full Unicode (emoji, CJK, Arabic, and beyond), URL-safe Base64 variant, file drag-and-drop, and data URI output. No data is sent to any server.

Key Features

  • Text → Base64: Encode any UTF-8 text, including emoji and international characters
  • Base64 → Text: Decode Base64 strings with automatic whitespace stripping and padding restoration
  • URL-safe mode: Produces +-, /_, no = padding — safe for URLs and filenames
  • File encoding: Upload or drag-and-drop any file to produce a Base64 data URI
  • Auto-detection: Automatically detects URL-safe chars, data URI prefixes, and missing padding
  • Smart warnings: Surface recoverable issues (Latin-1 fallback, binary data, stripped whitespace) without blocking output
  • Round-trip swap: One-click swap of output → input to verify encode/decode round-trips

Common Use Cases

Web Development & APIs

  • Encode authentication credentials for HTTP Basic Auth headers (Authorization: Basic <base64>)
  • Embed small images, fonts, or SVG files directly in HTML or CSS as data URIs
  • Encode binary payloads for JSON APIs that do not support raw binary fields
  • Decode JWT (JSON Web Token) header and payload segments to inspect claims
  • Encode and decode query string parameters that contain special characters

Security & Cryptography

  • Decode Base64-encoded certificates, public keys, and PEM files
  • Inspect Base64-encoded cryptographic signatures and digests
  • Encode binary hash outputs (SHA-256, HMAC) for safe transport in text-based protocols
  • Decode SAML assertions and OAuth tokens for debugging
  • Verify Base64 encoding of challenge-response values in authentication flows

DevOps & Configuration

  • Encode Kubernetes secrets for use in kubectl YAML manifests
  • Decode base64-encoded environment variables in CI/CD pipeline logs
  • Encode configuration files for embedding in environment variables or Helm values
  • Decode Docker registry auth tokens from ~/.docker/config.json
  • Inspect encoded values in .env files and infrastructure-as-code templates

Email & Data Transfer

  • Understand MIME encoding used by email attachments (Base64 is the standard email attachment encoding)
  • Decode email headers encoded with Base64 for non-ASCII subjects and sender names
  • Encode binary file content for safe transfer through text-only channels
  • Debug Base64-encoded payloads in webhook events and message queue bodies

Technical Details

Why Base64 exists

Binary data — images, certificates, executable files — cannot be safely embedded in text-based formats like JSON, XML, HTML, or HTTP headers. Base64 represents any binary byte sequence using only 64 printable ASCII characters (A–Z, a–z, 0–9, +, /), making binary data universally portable across text-based protocols and systems.

The trade-off is size: every 3 bytes of input become 4 characters of Base64 output, an overhead of approximately 33%.

Standard vs URL-safe Base64

VariantCharacters usedPaddingUse case
Standard (RFC 4648 §4)A–Z a–z 0–9 + /=General purpose, MIME, email
URL-safe (RFC 4648 §5)A–Z a–z 0–9 - _NoneURLs, filenames, JWT, cookies

The + and / characters in standard Base64 have special meaning in URLs (+ is a space, / is a path separator), so URL-safe Base64 substitutes - and _ and drops the = padding that would require percent-encoding.

Unicode handling

JavaScript’s built-in btoa() function only handles Latin-1 (characters up to U+00FF). This tool uses TextEncoder to convert any UTF-8 string to a byte array before encoding, which correctly handles the full Unicode range — emoji, CJK characters, Arabic, Cyrillic, and any other script. Decoding uses TextDecoder with strict UTF-8 validation, falling back to Latin-1 if the byte sequence is not valid UTF-8.

Padding

Base64 works in 3-byte (24-bit) blocks. When input length is not a multiple of 3, one or two = padding characters are appended to make the output a multiple of 4 characters. Many decoders accept unpadded input; this tool auto-restores missing padding rather than erroring.

Base64 Encoding Reference

Input bytes:   M        a        n
Binary:        01001101 01100001 01101110
6-bit groups:  010011  010110  000101  101110
Base64 index:  19      22      5       46
Base64 chars:  T       W       F       u
Output:        TWFu    (no padding needed — 3 bytes = 4 chars exactly)

Padding examples

Input    Bytes   Base64 output   Padding
"A"      1       QQ==            2 × '='
"AB"     2       QUI=            1 × '='
"ABC"    3       QUJD            none

Common encoded values

Text             Standard Base64           URL-safe Base64
Hello, World!    SGVsbG8sIFdvcmxkIQ==     SGVsbG8sIFdvcmxkIQ
{"a":1}          eyJhIjoxfQ==              eyJhIjoxfQ
true             dHJ1ZQ==                  dHJ1ZQ
2024-01-01       MjAyNC0wMS0wMQ==          MjAyNC0wMS0wMQ

Frequently Asked Questions

Is my data safe? All encoding and decoding happens entirely in your browser using the Web Crypto and Encoding APIs. No data is sent to any server at any point.

Why does my decoded output look like gibberish? You are likely decoding a Base64-encoded binary file (image, PDF, compressed archive) rather than text. The tool will warn you when it detects non-printable bytes in the decoded output. Use the Download button to save the binary result, or check whether you intended to paste image data into a browser <img src="data:..."> tag.

Why does Base64 not equal length × 1.33? The 33% overhead is approximate. The exact formula is ceil(n / 3) × 4 where n is the input byte length. For a 1-byte input you get 4 characters — 300% overhead — because Base64 always pads to a 4-character boundary.

What is a data URI? A data URI (data:image/png;base64,iVBOR...) embeds file content directly in a URL. Browsers can use data URIs as src attributes for images, as CSS background-image values, and in other contexts where a URL is expected. This tool outputs full data URIs when you upload binary files.

What is the difference between Base64 and Base64url? Base64url (URL-safe Base64, RFC 4648 §5) replaces + with - and / with _, and omits = padding. This makes it safe to include in URLs, filenames, HTTP headers, and JWT tokens without percent-encoding. The encoded data is otherwise identical — just substitute the two characters and add padding if needed to decode.

Can I encode files larger than 200 KB? The tool automatically pauses for inputs over 200 KB to keep the browser responsive, but you can click “Process anyway” to proceed. For very large files (megabytes), consider using the base64 command-line utility or a scripting language: base64 -i input.bin -o output.txt on macOS/Linux.

Command-line equivalents

# Encode text
echo -n "Hello, World!" | base64
# SGVsbG8sIFdvcmxkIQ==

# Decode
echo "SGVsbG8sIFdvcmxkIQ==" | base64 --decode
# Hello, World!

# Encode a file
base64 -i image.png -o image.b64.txt

# URL-safe (macOS/Linux with tr)
echo -n "sure." | base64 | tr '+/' '-_' | tr -d '='
# c3VyZS4

# Node.js
Buffer.from("Hello, World!").toString("base64")         // encode
Buffer.from("SGVsbG8sIFdvcmxkIQ==", "base64").toString() // decode

# Python
import base64
base64.b64encode(b"Hello, World!").decode()              # encode
base64.b64decode("SGVsbG8sIFdvcmxkIQ==").decode()       # decode
base64.urlsafe_b64encode(b"sure.").rstrip(b"=").decode() # url-safe encode
From the same team