Base64 Encoder / Decoder

Convert text and files to and from Base64 encoding with URL-safe support

Base64 Encoder / Decoder

Convert text and files to and from Base64 encoding with support for URL-safe variants and custom padding options.

Overview

Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It's commonly used to encode binary data for transmission over media that only support text content, such as email or URLs.

Features

πŸ”„ Bidirectional Conversion

  • Encode: Convert plain text or files to Base64
  • Decode: Convert Base64 back to original text or file content
  • Auto-detection of Base64 input for smart mode switching

πŸ›‘οΈ URL-Safe Encoding

  • Replace + with - and / with _
  • Perfect for tokens, URLs, and query parameters
  • Optional padding removal for shorter strings

πŸ“ File Support

  • Load any file and convert to Base64
  • Download encoded/decoded results
  • Maintains file information during conversion

⚑ Quick Actions

  • Copy to clipboard with one click
  • Download results as text files
  • Character count tracking
  • Clear all with one button

How to Use

Encoding Text to Base64

  1. Enter your text in the Input textarea
  2. Ensure Encode mode is selected (default)
  3. Click Run to convert
  4. The Base64 output appears in the Output textarea
  5. Click Copy or Download to save the result

Example:

Input:  Hello, World!
Output: SGVsbG8sIFdvcmxkIQ==

Decoding Base64 to Text

  1. Paste Base64 string in the Input textarea
  2. Select Decode mode (or let auto-detect switch for you)
  3. Click Run to convert
  4. The decoded text appears in the Output textarea

Example:

Input:  SGVsbG8sIFdvcmxkIQ==
Output: Hello, World!

URL-Safe Encoding

Enable URL-Safe mode when encoding data for:

  • URL query parameters
  • JWT tokens
  • File names
  • API keys
  • Cookies

Standard Base64:

Hello, World! β†’ SGVsbG8sIFdvcmxkIQ==
Contains: + / =

URL-Safe Base64:

Hello, World! β†’ SGVsbG8sIFdvcmxkIQ
Contains: - _ (no padding)

Loading Files

  1. Click Load File button
  2. Select any file from your computer
  3. File content is automatically encoded to Base64
  4. Mode switches to Decode to show original content

Supported Files:

  • Text files (.txt, .csv, .json, etc.)
  • Images (.jpg, .png, .gif, etc.)
  • Documents (.pdf, .docx, etc.)
  • Any binary file

Options Explained

URL-Safe Mode

When to use:

  • Encoding data for URLs
  • Creating tokens that will be part of a URL
  • File names that need to be web-safe
  • API authentication headers

What it does:

  • Replaces + with - (hyphen)
  • Replaces / with _ (underscore)
  • These characters are URL-safe and don't need encoding

Strip Padding

When to use:

  • JWT tokens (they don't use padding)
  • Shorter string lengths
  • Systems that don't require padding

What it does:

  • Removes trailing = characters
  • Reduces string length
  • Padding is automatically restored on decode

Important: Padding is required for standard Base64 decoding. This tool automatically restores padding when needed.

Common Use Cases

1. Embedding Images in HTML/CSS

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA..." />
  • Encode image files to Base64
  • Embed directly in HTML or CSS
  • Reduces HTTP requests

2. JWT Tokens

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U
  • Use URL-safe encoding
  • Strip padding
  • Decode to read token contents

3. API Authentication

  • Encode credentials for Basic Auth
  • Format: username:password β†’ Base64
  • Used in Authorization headers

4. Data URLs

  • Embed fonts, icons, or small files
  • Reduce HTTP requests
  • Improve page load times

5. Email Attachments

  • MIME encoding for email attachments
  • Ensures binary data survives text-only transmission
  • Standard Base64 encoding

6. Storing Binary Data

  • Store binary data in text-based databases
  • JSON payloads with binary content
  • Configuration files

Technical Details

Character Set

Base64 uses 64 characters:

  • A-Z: 26 uppercase letters
  • a-z: 26 lowercase letters
  • 0-9: 10 digits
  • + /: 2 symbols (standard)
  • - _: 2 symbols (URL-safe)
  • =: Padding character

Encoding Process

  1. Convert text to UTF-8 bytes using TextEncoder
  2. Group bytes into 6-bit chunks
  3. Map each chunk to Base64 character
  4. Add padding (=) if needed to make length multiple of 4

Decoding Process

  1. Remove padding if present
  2. Convert Base64 characters to 6-bit chunks
  3. Combine chunks into 8-bit bytes
  4. Convert bytes to UTF-8 text using TextDecoder

Size Increase

Base64 encoding increases data size by approximately 33%:

  • 3 bytes (24 bits) β†’ 4 Base64 characters (24 bits)
  • 100 KB file β†’ ~133 KB Base64 string

Unicode Support

This tool uses TextEncoder and TextDecoder for full Unicode support:

  • βœ… Emoji: πŸ˜€ πŸŽ‰ ❀️
  • βœ… Special characters: Γ±, ΓΌ, Γ©
  • βœ… Asian languages: δ½ ε₯½, こんにけは, μ•ˆλ…•ν•˜μ„Έμš”
  • βœ… Mathematical symbols: βˆ‘, ∫, √

Browser Compatibility

Works in all modern browsers:

  • βœ… Chrome / Edge (Chromium)
  • βœ… Firefox
  • βœ… Safari
  • βœ… Opera
  • βœ… Mobile browsers

Uses standard web APIs:

  • btoa() / atob() for Base64 conversion
  • TextEncoder / TextDecoder for Unicode
  • FileReader for file handling

Troubleshooting

"Conversion failed" Error

Problem: Invalid Base64 string
Solution:

  • Check for extra whitespace or newlines
  • Verify the string uses Base64 characters only
  • Ensure padding is correct (or enable URL-safe mode)

Garbled Output

Problem: Wrong encoding/decoding mode
Solution:

  • Switch between Encode and Decode modes
  • Use URL-safe mode if input has - or _ characters
  • Check if padding needs to be restored

File Loading Issues

Problem: File won't load
Solution:

  • Try smaller files (browser memory limits)
  • Check file permissions
  • Ensure file is not corrupted

Character Count Mismatch

Problem: Output size unexpected
Solution:

  • Base64 is 33% larger than original
  • Padding adds up to 2 characters
  • URL-safe without padding is slightly shorter

Privacy & Security

βœ… Completely Private

  • All conversions happen in your browser
  • No data is sent to any server
  • Your files never leave your device

βœ… No Storage

  • Nothing is saved or logged
  • Clear data by closing the page
  • Refresh to reset everything

⚠️ Security Notes

  • Base64 is encoding, not encryption
  • Anyone can decode Base64 strings
  • Don't use for sensitive data without encryption
  • Not suitable for password storage

Best Practices

βœ… Do's

  • Use URL-safe for tokens and URLs
  • Remove padding for JWT tokens
  • Verify encoded data before transmission
  • Test decode before using in production
  • Use for appropriate data sizes (< 1 MB recommended)

❌ Don'ts

  • Don't use as encryption (it's reversible)
  • Don't encode very large files (browser limits)
  • Don't store passwords in Base64
  • Don't mix standard and URL-safe without converting
  • Don't forget to restore padding when needed

Keyboard Shortcuts

  • Ctrl/Cmd + Enter: Run conversion
  • Ctrl/Cmd + K: Clear all
  • Ctrl/Cmd + C: Copy output (when focused)

Examples

Example 1: Simple Text

Input:  The quick brown fox
Mode:   Encode
Output: VGhlIHF1aWNrIGJyb3duIGZveA==

Example 2: URL-Safe Token

Input:  user@example.com:secret123
Mode:   Encode (URL-safe + Strip padding)
Output: dXNlckBleGFtcGxlLmNvbTpzZWNyZXQxMjM

Example 3: Emoji Support

Input:  Hello πŸ‘‹ World 🌍
Mode:   Encode
Output: SGVsbG8g8J+RiyBXb3JsZCDwn4yN

Example 4: JSON Data

Input:  {"name":"John","age":30}
Mode:   Encode
Output: eyJuYW1lIjoiSm9obiIsImFnZSI6MzB9

Example 5: Multiline Text

Input:  Line 1
        Line 2
        Line 3
Mode:   Encode
Output: TGluZSAxCkxpbmUgMgpMaW5lIDM=

Frequently Asked Questions

What is Base64 used for?

Base64 is used to encode binary data into text format for transmission over text-based protocols like HTTP, email, and JSON.

Is Base64 encryption?

No! Base64 is encoding, not encryption. Anyone can decode it. Never use it for security purposes.

Why does the output have = at the end?

The = characters are padding to make the output length a multiple of 4. You can remove them with the "Strip Padding" option.

Can I encode images?

Yes! Use the "Load File" button to select an image. The Base64 output can be used in data URIs.

What's the difference between standard and URL-safe?

URL-safe replaces + with - and / with _ because these don't need URL encoding.

Why is the output larger than the input?

Base64 encoding increases size by about 33% due to the encoding scheme.

Can I decode Base64 from other sources?

Yes! Just paste any valid Base64 string and click Decode.

Is there a size limit?

Browser memory limits apply (typically several hundred MB), but we recommend keeping files under 10 MB for best performance.

Related Tools

  • URL Encoder/Decoder - For URL-safe string encoding
  • JSON Formatter - Format and validate JSON data
  • Text Diff Checker - Compare encoded/decoded versions
  • Image Editor - Edit images before encoding

Technical Support

Common Patterns

Basic Auth Header:

Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

Data URI:

data:[MIME-type];base64,[Base64-encoded-data]

JWT Structure:

[header].[payload].[signature]
All three parts are Base64 URL-safe encoded

Credits

This tool uses standard browser APIs for Base64 conversion with enhanced Unicode support via TextEncoder/TextDecoder for proper handling of international characters.