Base64 Encode & Decode Online

Encode Text, Files, Images & Data to Base64 — free, instant, browser-based. No upload, no signup.

Plain Text
Base64 Output
0 input chars0 output charsSize ratio:
What is Base64?

Base64 is a binary-to-text encoding scheme that represents binary data using 64 printable ASCII characters (A–Z, a–z, 0–9, + and /).

It is commonly used to embed images or files in HTML/CSS (data URLs), transmit binary data over email (MIME), store credentials in HTTP headers, and transfer data in JSON APIs.

Encoded output is approximately 33% larger than the original binary data.

How to Use the Base64 Encoder & Decoder

A free, instant, browser-based Base64 converter tool — no software, no upload, no account needed.

1

Choose Encode or Decode

Select the mode using the toggle at the top of the tool. Encode converts plain text or files into a Base64 string. Decode converts a Base64 string back into readable text or data.

2

Enter your input

For text, type or paste directly into the input panel. For files (images, PDFs, audio, video, CSV, ZIP, and more), click Upload File or drag and drop the file onto the panel.

3

Get your output instantly

The result appears in the output panel in real time as you type or immediately after file upload. No button click needed.

4

Copy or swap

Click Copy on the output panel to send the result to your clipboard. Use the ⇄ swap button to push the output back into the input and switch modes — useful for round-trip testing.

What Is Base64 Encoding?

Base64 is a binary-to-text encoding scheme standardized in RFC 4648. It represents arbitrary binary data using a set of 64 printable ASCII characters: A–Z, a–z, 0–9, +, and /, plus = as padding.

Every 3 bytes of binary input are mapped to 4 Base64 characters, making the encoded output approximately 33% larger than the source. For example, the string Hello encodes to SGVsbG8=.

A Base64Url variant (used in JWTs and URL-safe contexts) replaces + with - and / with _ to avoid conflicts in URLs.

Why Is Base64 Used?

  • Embedding binary files (images, PDFs, audio) in HTML, CSS, or JSON where text-only data is expected
  • Email attachments — SMTP is a text protocol, so binary files must be Base64-encoded (MIME)
  • JWT (JSON Web Tokens) — header and payload are Base64Url-encoded JSON
  • HTTP Basic Authentication — credentials are sent as Base64-encoded username:password
  • Data URIs — embed images directly in CSS/HTML without a separate HTTP request
  • API payloads — safely include binary data in JSON or XML without corrupting the structure

Common Use Cases for Base64 Encode & Decode

From converting images to Base64 for web embedding, to decoding JWT tokens and API responses — this tool covers the full developer workflow.

Embed images in HTML/CSS

Convert PNG, JPG, WEBP, or SVG to Base64 data URLs and use them directly in <img> src attributes or CSS background-image without needing a server.

Transmit files in JSON APIs

Encode PDFs, audio, video, or any binary file to Base64 to safely include them inside JSON or XML API request/response bodies.

Decode JWT tokens

Inspect the header and payload of any JSON Web Token by decoding each Base64Url segment to readable JSON — ideal for debugging authentication flows.

Email attachments (MIME)

Email protocols require binary attachments to be Base64-encoded. Use this tool to encode or verify MIME-encoded content.

HTTP Basic Auth credentials

HTTP Basic Authentication transmits credentials as Base64-encoded username:password. Encode or decode these values quickly.

Debug encoded API responses

Many APIs return Base64-encoded binary payloads. Paste the encoded string to instantly inspect the underlying data without writing code.

Base64 Encoding in Popular Languages

Use our online tool for quick conversions, or reference the code snippets below for JavaScript, Python, PHP, Java, and C# implementations.

JavaScript / Node.jsEncode & Decode examples

Encode to Base64

// Encode (browser)
btoa(unescape(encodeURIComponent("Hello World")));

// Encode (Node.js)
Buffer.from("Hello World").toString("base64");

Decode from Base64

// Decode (browser)
decodeURIComponent(escape(atob("SGVsbG8gV29ybGQ=")));

// Decode (Node.js)
Buffer.from("SGVsbG8gV29ybGQ=", "base64").toString("utf8");
PythonEncode & Decode examples

Encode to Base64

import base64
base64.b64encode(b"Hello World").decode("utf-8")

Decode from Base64

import base64
base64.b64decode("SGVsbG8gV29ybGQ=").decode("utf-8")
PHPEncode & Decode examples

Encode to Base64

base64_encode("Hello World"); // returns SGVsbG8gV29ybGQ=

Decode from Base64

base64_decode("SGVsbG8gV29ybGQ="); // returns Hello World
JavaEncode & Decode examples

Encode to Base64

import java.util.Base64;
Base64.getEncoder().encodeToString("Hello World".getBytes());

Decode from Base64

new String(Base64.getDecoder().decode("SGVsbG8gV29ybGQ="));

Base64 vs Other Encoding Formats

FormatOverheadUse case
Base64~33% largerBinary data in text channels (emails, JSON, HTML)
Hex (Base16)~100% largerCryptographic hashes, color codes, binary inspection
Binary~700% largerLow-level bitwise debugging and learning
URL EncodingVariableSafe encoding of special characters in URLs
UTF-80% (text)Standard character encoding for text data

Frequently Asked Questions about Base64

Everything you need to know about Base64 encoding, decoding, file conversion, and developer usage.

Related Developer Tools