B64EncodeDecode Logo
B64EncodeDecodePROencoderbase64.com
RFC 4648 & RFC 2045 Compliant|Web Worker Powered

Base64 Encode& Decode Online in Real-Time

Encode and decode text, files, images, and data URIs instantly. 100% private in-browser execution with zero server latency or data uploads.

0ms Network Latency (100% Client-Side)
Image & Audio Live Visualizer
1-Click Code Snippets (JS, Python, Go, cURL)
Worker Status: Idle / Ready|Overhead: +33.3%
INPUT0 chars • 0 bytes
100% In-Browser
OUTPUT0 chars • 0 bytes

Live Visual Media & Payload Inspector

Auto-Detect

Click to Browse or Drag & Drop Any File

Upload any image (PNG, JPG, SVG, WebP, GIF), audio (MP3, WAV), PDF, or JSON payload to preview and encode instantly.

PNG • JPG • SVG • WebPMP3 • WAV • JSON • PDF100% In-Browser

Developer Code Snippet Generator

Ready-to-use Implementation
// Select an option above to generate code

Competitive Edge

Engineered to Replace Legacy Online Encoders

Here is why developers, security teams, and designers choose B64EncodeDecode over traditional tools.

Zero Server Uploads

100% Client-Side Privacy

Competitors upload your files and data to their remote servers. B64EncodeDecode executes 100% in your local browser sandbox via Web Workers.

Real-Time Preview

Visual Media & Audio Inspector

Instantly preview Base64-encoded PNG, JPEG, SVG, WebP, GIF, PDF, audio waveforms (MP3/WAV), and formatted JSON trees without downloading.

Developer Suite

Multi-Language Code Export

Generate copy-ready implementation code in JavaScript (Browser & Node.js Buffer), HTML <img>, CSS url(), Python 3, Golang, PHP, and cURL.

Auto-Fix Malformed Strings

Smart Diagnostics & 1-Click Repair

Pinpoints exact corrupted character indexes, missing padding '=', and converts between standard Base64 and URL-safe Base64URL with one click.

RFC 4648 & RFC 2045

MIME 76-Char Chunks & Charset Suite

Support for UTF-8, ASCII, Latin-1, UTF-16, Unix LF / Windows CRLF normalization, and RFC 2045 76-character chunking for emails.

High Performance

Zero Latency Web Workers

Large files up to several gigabytes are processed smoothly in asynchronous background worker threads without freezing your user interface.

Technical Specification

How Base64 Encoding Works Under the Hood

Understanding the RFC 4648 binary translation standard and 6-bit pack mechanics.

1The 3-Byte to 4-Character Ratio (+33.3% Overhead)

Base64 takes binary data (8-bit bytes) and converts it into a set of 64 printable ASCII characters. Because 2^6 = 64, each Base64 character represents exactly 6 bits of data. Three 8-bit bytes (24 bits total) are split into four 6-bit groups:

CharacterASCII Code8-Bit Binary6-Bit SplitBase64 DecimalBase64 Output
M7701001101010011 (19)19T
a9701100001010110 (22)22W
n11001101110000101 (5) & 101110 (46)5, 46Fu

Standard Base64 vs URL-Safe Base64URL (RFC 4648)

Standard Base64
  • • Uses characters: + and /
  • • Uses padding: = at the end
  • • Requires percent-encoding inside URLs (%2B, %2F)
Base64URL (Safe for URLs & JWTs)
  • • Replaces + with - (hyphen)
  • • Replaces / with _ (underscore)
  • • Padding (=) is completely omitted

Comprehensive Developer Reference & Guide

The Complete Guide to Base64 Encode and Decode

Learn everything about Base64 encoding, the RFC 4648 standard, binary conversions, Data URIs, image encoding, command-line usage, and code implementations in Python, JavaScript, PHP, Golang, and Linux.

1. What is Base64 Encoding and How Does the RFC 4648 Standard Work?

Base64 encode is a group of binary-to-text encoding schemes that translate binary data (bytes) into an ASCII string format. The primary purpose of base64 encoding is to allow binary assets—such as images, compressed zip files, audio clips, encryption keys, and compiled byte arrays—to be safely transmitted over network channels and communication protocols designed strictly for plain ASCII text (such as HTTP headers, email MIME protocols via SMTP, XML payloads, and JSON REST APIs) without data corruption.

Under the formal RFC 4648 base64 encoding standard, the Base64 alphabet consists of exactly 64 printable ASCII characters:

  • Uppercase Letters (26): A-Z (Index values 0 to 25)
  • Lowercase Letters (26): a-z (Index values 26 to 51)
  • Numeric Digits (10): 0-9 (Index values 52 to 61)
  • Special Symbols (2): + (plus) and / (slash) (Index values 62 and 63)
  • Padding Character: = (equals sign) used to align byte boundaries when the input length is not divisible by 3.

Because 2^6 = 64, each character in a base64 encoded string represents exactly 6 bits of raw binary data. During the encoding process, the computer takes groups of three 8-bit bytes (24 bits in total) and partitions them into four 6-bit integers. Each 6-bit integer maps directly to a character in the 64-character alphabet table. As a mathematical consequence, any data converted using a base64 encoder incurs an exact +33.3% size overhead (4 output characters for every 3 input bytes).

2. Base64 Encode and Decode Online: Converting Text, Strings & Characters

When you use an online base64 encode tool or base64 decoder, the conversion handles various character encodings and formatting variations:

Encoding Plain Text to Base64

To base64 encode text, the raw characters (e.g. UTF-8 strings containing Latin characters, Asian ideographs, Arabic text, or emojis) are first serialized into a binary byte sequence via TextEncoder, and then translated into standard Base64 characters. You can also enable line-by-line mode to encode multiple credentials or log entries independently.

Decoding Base64 to Text & Bytes

When you decode base64 online, the base64 converter parses the 6-bit character indexes back into an 8-bit Uint8Array byte buffer. Our smart engine automatically inspects the payload, repairs missing trailing = padding, and decodes binary byte arrays into readable UTF-8 strings.

Our tool acts as a unified base64 decode and encode studio: simply paste your text or Base64 string into the input area. The Auto-Detect engine immediately identifies whether your input is plain text, Base64, a Data URI, or JSON, and executes the optimal transformation with zero manual toggling required.

3. Image to Base64, Base64 to Image, PDF & File Conversions (Data URIs)

Modern web development frequently relies on inline binary embedding using Data URIs. By using our base64 image encoder, you can convert image to base64 and embed visual assets directly inside your HTML markup or CSS stylesheets, reducing additional HTTP round-trip requests for small UI icons, favicons, badges, and splash illustrations.

Supported Image & Media Formats:

  • PNG: data:image/png;base64,...
  • JPEG / JPG: data:image/jpeg;base64,...
  • SVG Vector: data:image/svg+xml;base64,...
  • WebP: data:image/webp;base64,...
  • GIF: data:image/gif;base64,...
  • PDF Document: data:application/pdf;base64,...

How to base64 encode a file: With our interactive base64 file encoder, you can drag and drop any file (such as images, PDF documents, JSON config files, MP3 audio, or binary blobs) directly onto the inspector surface. The tool converts the binary data into an RFC 4648 Base64 string instantly in your browser, displays a real-time visual preview, and provides 1-click buttons to copy the raw string, HTML <img> tag, CSS url() property, or download the decoded file.

4. Base64 Encode & Decode in Programming Languages and Command Line (CLI)

Developers frequently need to implement Base64 encoding in backend APIs, build scripts, automation pipelines, and server configurations. Below is a quick cheat sheet for major programming languages and command-line environments:

Python (base64 encode python & python base64 decode)Python 3.x Standard Library

import base64

# Base64 Encode String Python
raw_data = "Hello, World!".encode("utf-8")
encoded_b64 = base64.b64encode(raw_data).decode("utf-8")
print("Encoded:", encoded_b64)  # Output: SGVsbG8sIFdvcmxkIQ==

# Base64 Decode Python
decoded_bytes = base64.b64decode(encoded_b64)
decoded_str = decoded_bytes.decode("utf-8")
print("Decoded:", decoded_str)  # Output: Hello, World!

JavaScript & Node.js (base64 encode in js & nodejs)Browser & Node Runtime

// Browser JavaScript
const encoded = btoa(unescape(encodeURIComponent("Hello, World!")));
const decoded = decodeURIComponent(escape(atob(encoded)));

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

PHP (php base64 encode & php decode base64)PHP 7.x / 8.x Native

<?php
// PHP Base64 Encode
$encoded = base64_encode("Hello, World!");

// PHP Base64 Decode
$decoded = base64_decode($encoded);
echo $decoded;
?>

Golang (golang base64 decode & base64 encode golang)Go standard encoding/base64

package main
import (
    "encoding/base64"
    "fmt"
)

func main() {
    data := []byte("Hello, World!")
    encoded := base64.StdEncoding.EncodeToString(data)
    decoded, _ := base64.StdEncoding.DecodeString(encoded)
    fmt.Printf("Encoded: %s\nDecoded: %s\n", encoded, string(decoded))
}

Linux Terminal, Bash & Windows PowerShell (base64 command line)CLI & Shell Scripts

# Linux Command Base64 Encode String
echo -n "Hello, World!" | base64

# Linux Base64 Decode Command Line
echo -n "SGVsbG8sIFdvcmxkIQ==" | base64 -d

# Base64 Encode File Linux
base64 -w 0 input.png > image.b64

# Windows PowerShell Base64 Encode
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("Hello, World!"))

# Windows PowerShell Base64 Decode
[Text.Encoding]::UTF8.GetString([Convert]::FromBase64String("SGVsbG8sIFdvcmxkIQ=="))

5. Base64 for HTTP Basic Authentication, Passwords & JSON Web Tokens (JWT)

In HTTP API security, the HTTP Basic Authentication scheme (RFC 7617) requires clients to send credentials in an Authorization request header. The client combines the username and password separated by a colon (username:password) and converts it with a base64 encode username and password routine:

Authorization: Basic YWRtaW46c2VjcmV0cGFzc3dvcmQxMjM=

Similarly, JSON Web Tokens (JWT) rely on Base64URL encoding to pack the JOSE header, JSON payload claims, and cryptographic signature into three period-delimited URL-safe parts (header.payload.signature). Because standard Base64 characters + and / carry special meaning in web URLs and query strings, Base64URL substitutes them with - and _ while omitting padding = characters.

6. Why B64EncodeDecode is the Safest & Fastest Online Base64 Tool

Many legacy online converters (such as base64encode.org) transmit your sensitive inputs, passwords, proprietary code, and confidential images across the internet to remote servers for processing.

B64EncodeDecode (encoderbase64.com) is fundamentally different:

  • 100% In-Browser Execution: All string transformations, byte array conversions, and file readings happen entirely inside your local browser memory using JavaScript Web Workers and the HTML5 FileReader API.
  • Zero Server Uploads: No files, strings, passwords, or telemetry data are ever transmitted to any external backend server or database.
  • Instant Zero-Latency Performance: Real-time processing with sub-millisecond conversion times even for large megabyte-sized assets.
  • Live Visual Previews: Instant rendering for PNG, JPEG, SVG, WebP, GIF, PDF documents, MP3/WAV audio streams, and JSON trees directly on-page.
  • Smart Error Auto-Repair: Automatically pinpoints malformed characters, corrects invalid byte padding, and normalizes line endings with a single click.

Frequently Asked Questions

Everything You Need to Know About Base64

Quick answers to the most common questions about Base64 encoding, decoding, file sizes, URL safety, and image conversions.

What is Base64?

Base64 is a binary-to-text encoding scheme that converts binary data (such as files, images, or byte arrays) into a sequence of 64 printable ASCII characters (A-Z, a-z, 0-9, +, and /). It is formally defined in IETF specification RFC 4648.

What is Base64 encoding?

Base64 encoding is the process of taking 8-bit binary bytes (or plain text strings) and translating them into 6-bit units. Each 6-bit unit maps to one of 64 standard ASCII characters, ensuring binary data can be safely transmitted over text-only protocols like email (MIME), HTTP headers, and JSON APIs without character corruption.

How does Base64 encoding work?

Base64 takes 3 bytes of binary data (24 bits in total) and splits them into 4 groups of 6 bits each (4 × 6 = 24 bits). Each 6-bit integer (value 0 to 63) corresponds to an ASCII character in the Base64 index table. If the input data is not an exact multiple of 3 bytes, padding characters (=) are added at the end.

How do I encode a string to Base64?

You can encode a string to Base64 instantly online by typing or pasting your text into our free Base64 encoder tool. In JavaScript, you can use btoa(string); in Python, base64.b64encode(string.encode('utf-8')); and in Linux CLI, echo -n 'text' | base64.

How do I decode a Base64 string?

You can decode a Base64 string back to its original plain text or binary file by pasting the Base64 string into our tool's input box with Auto-Detect or Decode mode enabled. In JavaScript, use atob(base64String); in Python, base64.b64decode(base64String).decode('utf-8'); and in Linux CLI, echo 'base64String' | base64 -d.

What is Base64 used for?

Base64 is widely used for: (1) Embedding images and SVG graphics directly in HTML and CSS as Data URIs, (2) HTTP Basic Authentication headers (Authorization: Basic credentials), (3) Email attachments via MIME RFC 2045, (4) Storing cryptographic keys and certificates (PEM format), and (5) Web tokens and APIs (JWT, JSON payloads).

What does Base64 look like?

A Base64 string looks like a continuous alphanumeric string consisting of uppercase letters (A-Z), lowercase letters (a-z), numbers (0-9), plus signs (+), forward slashes (/), and optional equals signs (=) at the end for padding (for example: SGVsbG8gV29ybGQ=).

What is an example of Base64?

An example of Base64 encoding is the text 'Hello World', which encodes to SGVsbG8gV29ybGQ=. Another example is the phrase 'Base64 encode', which encodes to QmFzZTY0IGVuY29kZQ==.

Is Base64 encryption, and is Base64 secure?

No, Base64 is NOT encryption and provides zero cryptographic security. Base64 is simply an encoding format designed for data transmission compatibility. Anyone who intercepts a Base64 string can decode it back to the original plaintext in milliseconds without a password or key. Never use Base64 alone to protect sensitive passwords or secret keys.

Why does Base64 end with = or ==?

Base64 processes data in 3-byte (24-bit) blocks. If your input data length is not evenly divisible by 3, padding characters (=) are added at the end to ensure the output length is a multiple of 4 characters: 1 byte remaining results in == padding, 2 bytes remaining results in = padding, and 0 bytes remaining requires no padding.

What are valid and invalid Base64 characters?

Valid standard Base64 characters include A-Z, a-z, 0-9, +, /, and = for padding (or - and _ in Base64URL). Any whitespace, punctuation marks like !, @, #, $, %, ^, &, *, (, ), or non-ASCII characters outside this 64-character set are invalid and will trigger decoding errors unless cleaned with an auto-repair tool.

Does Base64 encoding reduce file size?

No, Base64 encoding actually increases file size by approximately 33.3% (ratio of 4/3). Because 3 binary bytes (24 bits) are expanded into 4 ASCII characters (32 bits), the resulting Base64 string is always larger than the original binary data.

What is Base64URL encoding?

Base64URL (RFC 4648 Section 5) is a URL-safe and filename-safe variant of Base64. It replaces the plus sign (+) with a hyphen (-), replaces the forward slash (/) with an underscore (_), and completely omits trailing equals sign (=) padding characters so the string can be safely used in web URLs, query parameters, and JWT tokens without percent-encoding.

What is the difference between Base64 and Base64URL?

Standard Base64 uses + and / with = padding, which require URL encoding (%2B and %2F) when placed in URLs. Base64URL substitutes + with - and / with _, and removes all = padding, making it 100% URL-safe, cookie-safe, and token-safe out of the box.

What is a Base64 image?

A Base64 image is an image file (such as PNG, JPEG, GIF, WebP, or SVG) that has been converted into a Base64-encoded text string and formatted as a Data URI (e.g., data:image/png;base64,iVBORw0KGgo...). This allows the image to be embedded directly into HTML <img src='...'> tags or CSS background-image: url(...) properties without an external image URL.

How do I convert an image to Base64?

To convert an image to Base64, simply drag and drop your image file (PNG, JPG, SVG, WebP, or GIF) into our online tool's inspector dropzone. The tool will instantly encode the image into a Base64 Data URI in your browser and provide 1-click buttons to copy the raw Base64 string, HTML <img> tag, or CSS snippet.