Base64 Encoder/Decoder

Base64 Encoder/Decoder

Encode & decode Base64, Base32, Hex, Base58 and more — fast, private, no server upload.

What is Base64 Encoding?

Base64 is a binary-to-text encoding scheme defined in RFC 4648. It represents binary data using 64 ASCII characters (A-Z, a-z, 0-9, +, /), making it safe for transmission through text-based protocols like email (MIME), HTTP headers, and URLs.

The name "Base64" refers to the 64-character alphabet used. Each character represents exactly 6 bits of data, so 3 bytes (24 bits) of input produce 4 Base64 characters. This results in a ~33% size increase, which is the trade-off for text compatibility.

Base Encoding Examples

Try these real-world examples instantly. Click Decode → to load each example into the tool and see the result.

FormatDescriptionSampleTry
Base64URLJWT authentication tokeneyJhbGciOiJIUzI1…
Base64Data URI — 1×1 transparent PNGdata:image/png;ba…
Base64 PEMPEM public key certificate-----BEGIN PUBLIC…
Base58Bitcoin genesis block address1A1zP1eP5QGefi2D…
Base32TOTP authenticator secretJBSWY3DPEHPK3PXP
HexSHA-256 hash of empty stringe3b0c44298fc1c14…
Base85Ascii85-encoded "Man is d…"9jqo^BlbD-BleB1D…
Base91Base91 round-trip samplefPNKd
Base62Short URL / unique ID7N42dgm5tFLK9N8M…
Base64 MIMEEmail attachment (76-char wrap)TWFuIGlzIGRpc3Rp…

Base Encoding Formats Compared

This tool supports 11 base encoding formats. Each has different trade-offs between efficiency, character set, and use case:

FormatAlphabetOverheadUse Case
Base64A-Z, a-z, 0-9, +, /+33%General purpose, MIME email
Base64URLA-Z, a-z, 0-9, -, _+33%JWT, OAuth, URLs
Base32A-Z, 2-7+60%TOTP, DNS, case-insensitive
Hex0-9, A-F+100%Colors, MAC, hashes
Base581-9, A-H, J-N, P-Z, a-k, m-z+37%Bitcoin, IPFS
Base620-9, A-Z, a-z+36%Short URLs, unique IDs
Base85! to u (ASCII 33-117)+25%PostScript, PDF, ZeroMQ
Base9191 printable ASCII+14-23%Maximum efficiency

Common Use Cases

  • JWT Tokens — Header and Payload are Base64URL-encoded. Decode them to inspect claims like expiration and issuer.
  • PEM Certificates — TLS/SSL certificates use Base64 with -----BEGIN CERTIFICATE----- headers. Decode to inspect certificate details.
  • Data URIs — Embed images in HTML/CSS as data:image/png;base64,.... Encode files to generate Data URIs.
  • Email Attachments — MIME uses Base64 with 76-character line wrapping to encode binary attachments in email.
  • Bitcoin Addresses — Base58Check encoding removes confusing characters (0, O, I, l) for human-readable addresses.
  • TOTP Secrets — Google Authenticator uses Base32-encoded secrets for two-factor authentication setup.

Common Base Encoding Errors and How to Fix Them

Invalid padding

Symptom: Invalid padding: expected 0-2 '=' characters or decoding fails silently.

Cause: Base64 strings must have a length that is a multiple of 4. Missing = padding characters break the decoder.

Fix: Add = characters until the string length is a multiple of 4. This tool does it automatically — look for the "Auto-repaired: added padding" message.

Invalid character in Base64 string

Symptom: Invalid character error when decoding.

Cause: The string contains characters outside the Base64 alphabet. Common culprits: - and _ (Base64URL characters) in a standard Base64 decoder.

Fix: Check if the string is Base64URL-encoded (uses -_ instead of +/). Select the correct format or let auto-detect identify it.

Decoded output is garbled or unreadable

Symptom: The decoded result contains random characters or mojibake.

Cause: The wrong encoding format was selected. For example, a Base32 string decoded as Base64 produces garbage output.

Fix: Use auto-detect to identify the correct format, or manually try different formats until the output makes sense.

Base64URL vs Base64 confusion

Symptom: JWT tokens fail to decode with a standard Base64 decoder.

Cause: JWT uses Base64URL encoding which replaces + with - and / with _, and omits padding.

Fix: Select Base64URL format, or paste the JWT and let auto-detect handle it (strings starting with eyJ are automatically detected as JWT/Base64URL).

Odd-length hex string

Symptom: Odd-length hex string error when decoding hex.

Cause: Hex encoding uses 2 characters per byte, so the total length must be even. An odd-length string is missing a leading zero.

Fix: Prepend a 0 to make the length even. For example, change FFF to 0FFF.

Base Encoding in Your Language

Base64 encoding and decoding are available in all major programming languages through standard libraries:

LanguageModuleEncodeDecode
Node.jsBuffer (built-in)Buffer.from(str).toString('base64')Buffer.from(b64, 'base64').toString()
Pythonbase64 (built-in)base64.b64encode(data)base64.b64decode(s)
Javajava.util.Base64Base64.getEncoder().encodeToString(bytes)Base64.getDecoder().decode(s)
Goencoding/base64base64.StdEncoding.EncodeToString(data)base64.StdEncoding.DecodeString(s)
.NET/C#System.ConvertConvert.ToBase64String(bytes)Convert.FromBase64String(s)
PHPCore (built-in)base64_encode($data)base64_decode($s)
RubyBase64 (built-in)Base64.strict_encode64(data)Base64.strict_decode64(s)

How to Use This Tool

  1. Select Encode or Decode mode using the buttons above.
  2. In Encode mode, type or paste text, choose a format, and see the encoded result instantly.
  3. In Decode mode, paste an encoded string. The tool auto-detects the format and decodes it.
  4. If the decoded result is JSON, an image, or a PDF, an appropriate viewer is shown automatically.
  5. Use Code Snippets to copy ready-to-use code for HTML, CSS, Node.js, Python, and more.
  6. Check the Efficiency Comparison to see how different formats compare in size.

Base64 vs Base32 vs Base58

AspectBase64Base32Base58
Characters64 (case-sensitive)32 (case-insensitive)58 (no confusing chars)
Overhead+33%+60%+37%
Padding= (0-2)= (0-6)None
URL-safeNo (+, /)YesYes
Best forEmail, APIs, Data URIsTOTP, DNS, filenamesBitcoin, human-readable IDs

Technical Reference

Complete specification reference for all 11 supported base encoding formats:

FormatStandardAlphabetSizeIn:OutPaddingMax Line
Base64RFC 4648 §4A-Z, a-z, 0-9, +, /643:4= (0-2)
Base64URLRFC 4648 §5A-Z, a-z, 0-9, -, _643:4Optional
Base64 MIMERFC 2045A-Z, a-z, 0-9, +, /643:4= (0-2)76 (CRLF)
Base64 PEMRFC 7468A-Z, a-z, 0-9, +, /643:4= (0-2)64 (LF)
Base32RFC 4648 §6A-Z, 2-7325:8= (0/1/3/4/6)
Base32 HexRFC 4648 §70-9, A-V325:8= (0/1/3/4/6)
HexRFC 4648 §80-9, A-F161:2None
Base58Bitcoin wiki1-9, A-H, J-N, P-Z, a-k, m-z58~1:1.37None
Base62De facto0-9, A-Z, a-z62~1:1.34None
Base85Ascii85! to u (33-117)854:5None
Base91basE9191 printable ASCII91~1:1.23None

Frequently Asked Questions

Is Base64 encoding the same as encryption?

No. Base64 is encoding, not encryption. Anyone can decode Base64 without a key — it simply converts binary data to a text-safe format. For security, use actual encryption algorithms like AES or RSA. Never store sensitive data in Base64 alone.

Why does Base64 increase file size by 33%?

Base64 maps every 3 bytes of input to 4 ASCII characters using 6-bit groups. Since 4/3 ≈ 1.333, the output is always ~33% larger than the input. This trade-off provides safe text transmission through protocols that only support ASCII characters.

When should I use Base64URL instead of standard Base64?

Use Base64URL when the encoded string will appear in URLs or filenames. Standard Base64 uses + and / which have special meaning in URLs. Base64URL replaces them with - and _ and omits padding. JWT tokens always use Base64URL.

What is the difference between Base32 and Base64?

Base32 uses only uppercase letters (A-Z) and digits 2-7, making it case-insensitive with ~60% size overhead. Base64 uses 64 characters (case-sensitive) with ~33% overhead. Base32 is preferred for TOTP secrets and systems where case sensitivity is problematic.

Can I encode binary files like images with Base64?

Yes. Base64 is commonly used to embed images in HTML/CSS as Data URIs (data:image/png;base64,...), encode email attachments (MIME), and transmit binary data through JSON APIs. This tool supports file drag-and-drop for encoding any file type.

Why does Base58 exclude certain characters?

Base58 removes 0 (zero), O (uppercase o), I (uppercase i), and l (lowercase L) from the alphabet to prevent visual confusion when reading addresses. This makes it ideal for Bitcoin addresses and other human-readable identifiers.

What is the maximum size I can encode with this tool?

This tool supports files up to 10MB. All processing happens client-side in your browser, so performance depends on your device. For text input, there is no strict limit, but very large inputs (over 1MB) may cause slower processing.

Is it safe to paste sensitive data like tokens here?

Yes. All processing happens entirely in your browser using JavaScript. Your data is never sent to any server. You can verify this by checking the Network tab in your browser's developer tools.

Features

Multi-Format Support

Encode and decode 11 formats: Base64, Base64URL, MIME, PEM, Base32, Base32 Hex, Hex, Base58, Base62, Base85, and Base91. All in one tool.

Auto-Detection

Paste any encoded string and the tool automatically detects the format — JWT tokens, PEM certificates, Data URIs, hex strings, and more.

Smart Result Preview

Decoded results are analyzed automatically. JSON gets syntax highlighting, images get inline preview, and binary data shows a hex dump.

Code Snippets

Get ready-to-use code for HTML <img>, CSS background-image, Node.js Buffer, Python base64, JavaScript atob, and PowerShell.

File Support

Drag and drop files to encode them, or decode encoded strings back to downloadable files. Supports any file type up to 10MB.

100% Private

All processing happens in your browser using JavaScript. No data is ever sent to any server. Safe for production tokens and sensitive data.

Privacy & Security

Your data is processed entirely in your browser using JavaScript. Nothing is sent to any server. All encoding, decoding, format detection, and file processing happen locally. You can verify this by opening your browser's developer tools and checking the Network tab. This tool is safe to use with production data, API keys, certificates, and sensitive credentials.