Base64 Converter

Convert text and images to Base64 or decode Base64 strings instantly using a fast browser-based Base64 converter.

Plain Text Input
Loading Editor...
Base64 Output
Loading Editor...

Features

  • Text to Base64 Encoding: Safely convert plain text and UTF-8 strings into standard Base64 representation (RFC 4648).
  • Base64 to Text Decoding: Instantly reverse encoded Base64 strings back into readable plain text with full multi-byte character support.
  • Image to Base64 Data URL: Drag and drop any image (PNG, JPG, SVG, WebP, GIF) to generate ready-to-embed Data URL strings for HTML and CSS.
  • 100% In-Browser Privacy: All processing runs locally using your browser's native Web APIs. No text, tokens, or files are ever uploaded to a remote server.
  • One-Click Export: Copy encoded outputs directly to your clipboard or download them as raw text or binary files.
  • Developer Ecosystem: Pairs seamlessly with our JWT Decoder, URL Encoder, and JSON Formatter.

How it works

Base64 is a binary-to-text encoding algorithm specified by RFC 4648 that represents 8-bit binary data using a set of 64 printable ASCII characters. It is commonly used to transmit binary payloads through text-based protocols like HTTP, SMTP email, and JSON APIs without character corruption.

Choose Encode Text, Decode Text, or Image to Base64 above. Type or paste your input into the left editor to view the real-time conversion in the right editor. For image conversion, drop a file directly onto the canvas to generate a complete data:image/...;base64 URI.

How Base64 Encoding Works (RFC 4648)

Computers store data as bytes (8 bits). Many communication channels, such as email protocols (MIME) and early networking layers, were designed strictly for 7-bit ASCII text and could corrupt control characters or raw byte values. Base64 solves this by mapping any arbitrary sequence of bytes into a safe alphabet of 64 printable ASCII characters:

  • Uppercase letters: A–Z (indices 0–25)
  • Lowercase letters: a–z (indices 26–51)
  • Digits: 0–9 (indices 52–61)
  • Symbols: + and / (indices 62 and 63)
  • Padding: = (used when the input length is not a multiple of 3 bytes)

Every 3 bytes of binary input (3 × 8 = 24 bits) are divided into 4 groups of 6 bits (4 × 6 = 24 bits). Each 6-bit integer (value 0 to 63) indexes directly into the Base64 alphabet table.

Base64 vs. Base64URL: Key Differences

While standard Base64 works well for MIME email and general data storage, its reserved symbols cause issues inside URLs and HTTP headers. Here is how standard Base64 compares to URL-safe Base64:

FeatureStandard Base64 (RFC 4648 §4)Base64URL (RFC 4648 §5)
Index 62 Character+ (plus)- (hyphen / minus)
Index 63 Character/ (forward slash)_ (underscore)
Padding Character= (mandatory or standard)Typically omitted / unpadded
Primary Use CasesData URLs, email MIME bodies, XML signaturesJSON Web Tokens (JWT), URL query parameters, OAuth tokens

How to Encode & Decode Base64 in Code

Common implementations across modern programming languages:

JavaScript / TypeScript (Browser & Node.js)

// Modern Browser (UTF-8 Safe)
const text = "Hello World! 🚀";
const encoded = btoa(unescape(encodeURIComponent(text)));
const decoded = decodeURIComponent(escape(atob(encoded)));

// Node.js
const nodeEncoded = Buffer.from("Hello World!", "utf-8").toString("base64");
const nodeDecoded = Buffer.from(nodeEncoded, "base64").toString("utf-8");

Python 3

import base64

# Standard Base64 Encoding
raw_bytes = "Hello World!".encode("utf-8")
encoded_str = base64.b64encode(raw_bytes).decode("utf-8")  # "SGVsbG8gV29ybGQh"

# Standard Base64 Decoding
decoded_bytes = base64.b64decode(encoded_str)
decoded_str = decoded_bytes.decode("utf-8")  # "Hello World!"

Go (Golang)

package main

import (
    "encoding/base64"
    "fmt"
)

func main() {
    msg := "Hello World!"
    encoded := base64.StdEncoding.EncodeToString([]byte(msg))
    fmt.Println(encoded) // "SGVsbG8gV29ybGQh"

    decoded, _ := base64.StdEncoding.DecodeString(encoded)
    fmt.Println(string(decoded)) // "Hello World!"
}

Embedding Base64 Images as Data URLs

A Data URL allows binary assets (such as PNG or SVG icons) to be embedded directly inline inside HTML or CSS without an extra HTTP network request:

<!-- Embedding directly in an HTML image tag -->
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..." alt="Embedded Icon" />

/* Embedding directly inside a CSS stylesheet */
.icon {
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0...");
}

Best Practice: Keep Base64 Data URLs below 10–15 KB. For larger images, external file URLs leverage HTTP caching, CDN delivery, and parallel downloads more efficiently.

Related Developer Tools & Guides

Frequently Asked Questions

What is Base64 encoding used for?

Base64 encoding is primarily used to transmit binary data through channels that only reliably handle plain text (such as email bodies, JSON REST APIs, or URL query parameters). It is also commonly used to embed small icons and images directly inside HTML and CSS files as Data URLs, eliminating extra HTTP requests.

Is Base64 an encryption method?

No. Base64 is strictly an encoding format, not encryption. It provides zero confidentiality or security. Anyone with access to a Base64 string can decode it back to its original bytes without a secret key or password. Never use Base64 to protect sensitive credentials or passwords.

What is the difference between standard Base64 and Base64URL?

Standard Base64 (RFC 4648 §4) uses '+' and '/' as characters 62 and 63, and uses '=' for padding. Because '+', '/', and '=' have reserved syntactic meanings in URLs and file paths, Base64URL (RFC 4648 §5) replaces '+' with '-' (hyphen) and '/' with '_' (underscore), and typically omits '=' padding. Base64URL is standard in JSON Web Tokens (JWT) and URL tokens.

Does Base64 encoding increase file size?

Yes. Base64 encoding increases data size by approximately 33%. Every 3 input bytes (24 bits) are converted into 4 Base64 ASCII characters (4 bytes / 32 bits). When embedding large images as Base64 Data URLs, this size overhead and loss of browser caching should be weighed against reducing HTTP roundtrips.

Why does decoding my Base64 string produce garbled characters?

Garbled output usually occurs when decoding binary data (such as a compressed file, PDF, or image) as UTF-8 text, or when the original string was encoded using a different character encoding (such as ISO-8859-1 or Windows-1252) instead of standard UTF-8.

Is this online Base64 converter safe for private data?

Yes, 100%. All conversions execute purely in your client browser using JavaScript's native TypedArrays and FileReader APIs. No data or files are transmitted to our servers or stored in any database.