Skip to main content

    Base64 Encoder / Decoder

    Encode text to Base64 or decode Base64 strings

    0 characters · 1 lines

    0 characters · 1 lines

    Why Use Base64 Encoding?

    Base64 encoding is an essential web development tool that converts binary data into ASCII text format, making it safe for transmission over text-based protocols like HTTP, email, and JSON APIs. This free online Base64 encoder/decoder handles Unicode text perfectly, allowing developers to embed images in HTML/CSS, encode authentication tokens, transmit data in URLs, and work with APIs that require Base64 format.

    Whether you're embedding images as data URIs, encoding API credentials, preparing data for URL parameters, or debugging web requests, Base64 encoding ensures your data remains intact during transmission. Our tool uses proper Unicode handling with TextEncoder/TextDecoder, so accented characters and emojis encode correctly—unlike basic implementations that fail with non-ASCII text.

    Common Use Cases for Base64

    🖼️Data URIs & Embedded Images

    Embed small images, icons, and SVGs directly in HTML/CSS using data URIs (data:image/png;base64,...). Perfect for email templates, single-file HTML documents, and reducing HTTP requests. Commonly used in React/Vue components for inline icons and in CSS for background images that need to load instantly without additional server requests.

    🔐API Authentication & Tokens

    Encode API keys, Basic Authentication credentials (username:password), and JWT tokens for HTTP headers. Most REST APIs use Base64 for Authorization headers. Essential for testing APIs with curl/Postman and implementing authentication in web applications. Remember: Base64 is NOT encryption—always use HTTPS for sensitive data transmission.

    📧Email Attachments & MIME

    Email protocols (SMTP) use Base64 to encode attachments and non-ASCII text in MIME format. This ensures files and international characters transmit correctly through email servers that only support 7-bit ASCII. Critical for email automation, newsletter systems, and debugging email delivery issues with raw MIME messages.

    🔗URL-Safe Data Encoding

    Encode complex data structures for URL parameters, query strings, and browser localStorage. Useful for passing JSON objects in URLs, encoding state in shareable links, and working with OAuth redirect URLs. Combine with URL encoding when embedding Base64 in URLs to handle special characters like +, /, and =.

    How Base64 Encoding Works

    Base64 encoding converts binary data (8-bit bytes) into a text representation using 64 ASCII characters (A-Z, a-z, 0-9, +, /). The encoding process groups input bytes into 24-bit chunks (3 bytes), then splits them into four 6-bit groups. Each 6-bit value (0-63) maps to one of the 64 Base64 characters. The "=" character pads the output when the input length isn't divisible by 3.

    Our tool uses JavaScript's native TextEncoder to handle Unicode text properly before encoding. This is crucial for international characters—many Base64 tools fail with text like "café" or "日本語" because they don't encode UTF-8 bytes correctly. The encoded output is approximately 33% larger than the original because Base64 uses 6 bits per character instead of 8, trading size for text-safe transmission.

    For decoding, the tool accepts Base64 strings with or without whitespace/line breaks (automatically cleaned), validates the input, and uses TextDecoder to properly reconstruct Unicode text. All processing happens locally in your browser with a 300ms debounce—your data never leaves your device, ensuring complete privacy and security.

    Tips for Best Results

    • Security warning: Base64 is encoding, NOT encryption. Never use it to protect passwords or sensitive data. Anyone can decode Base64 instantly. Use HTTPS and proper encryption for security.
    • URL embedding: When using Base64 in URLs, combine with URL encoding to escape +, /, and = characters that break URL parsing.
    • Size considerations: Base64 increases data size by ~33%. For large images or files, consider direct file uploads instead of data URIs to avoid performance issues.
    • Line breaks: Some systems expect Base64 with line breaks every 76 characters (MIME format). Use Prefix & Suffix to add line breaks if needed.
    • Testing APIs: For debugging API requests, decode the Authorization header to verify credentials are formatted correctly (e.g., "Basic dXNlcjpwYXNz" decodes to "user:pass").
    • Data URIs: Format for images is "data:image/png;base64,[encoded-string]". For SVG, consider using plain URL encoding instead as it's more efficient.

    Related Tools

    Frequently Asked Questions