PureDevTools

Base64 Encoder / Decoder

Encode and decode Base64 — text, files, and data URIs, all in your browser

All processing happens in your browser. No data is sent to any server.

Encoding Variant

RFC 4648 standard Base64 — uses + / and = padding

Type or paste text above to see the Base64-encoded result.

You’re debugging an API response and the Authorization header contains dXNlcjpwYXNzd29yZA==. You need to know what’s inside — now, not after looking up the Python docs. Or you’re embedding a small SVG icon in a CSS stylesheet and need the data URI. Or your CI pipeline just failed with “invalid base64 input” and you need to figure out whether the string got corrupted in transit.

Why This Tool (Not base64encode.org or the Terminal)

Most Base64 tools online — base64encode.org, base64decode.org, the dozens of clones — upload your input to a server for processing. That means your API keys, JWT tokens, and credentials pass through someone else’s infrastructure. For encoding that can trivially run in a browser, that’s an unnecessary risk.

This tool runs entirely in your browser. The TextEncoder, btoa, and FileReader APIs do all the work — no network requests, no server logs, no third-party analytics touching your data. You can verify this: open DevTools Network tab, encode something, and watch zero requests fire.

The terminal (base64 command, Buffer.from()) is fine when you’re already in a terminal. But when you’re in the middle of a browser-based workflow — reading API docs, debugging in DevTools, editing a CSS file — switching to a terminal breaks your flow. This tool is the browser-native alternative.

What Is Base64 Encoding?

Base64 is a binary-to-text encoding scheme that converts binary data into a sequence of 64 printable ASCII characters. The character set consists of A–Z, a–z, 0–9, +, and /, with = used as a padding character to make the output length a multiple of four.

Base64 is not encryption — it is encoding. Its purpose is to allow binary data to pass safely through text-based systems and protocols. Common applications include:

The output of Base64 encoding is approximately 33% larger than the original data because every 3 bytes of input produce 4 ASCII characters of output.

Standard vs URL-safe Base64

There are two widely-used Base64 variants defined in RFC 4648:

Standard Base64 (RFC 4648 §4)

Standard Base64 uses + and / as the 62nd and 63rd characters, and pads the output with = to align to a four-character boundary.

Input:  Hello, World!
Output: SGVsbG8sIFdvcmxkIQ==

Standard Base64 is the most widely supported form, used in MIME encoding and most general-purpose libraries.

URL-safe Base64 (RFC 4648 §5)

URL-safe Base64 replaces + with - and / with _, producing strings that can be used directly in URLs, file names, and HTTP headers without percent-encoding. Padding characters are typically omitted.

Input:  Hello, World!
Output: SGVsbG8sIFdvcmxkIQ

URL-safe Base64 is the standard for:

How to Encode Text to Base64

Type or paste any text into the Encode tab. The tool produces the Base64 output instantly as you type. Because the browser’s native btoa() function only handles bytes (not Unicode strings), this tool first converts your text to UTF-8 bytes using the TextEncoder API before applying Base64 encoding. This ensures correct results for all characters including Chinese (中文), Japanese (日本語), Arabic (العربية), and emoji (🚀).

To switch to URL-safe output, select the URL-safe variant — the result replaces + with -, / with _, and removes the = padding.

How to Decode Base64

Switch to the Decode tab and paste your Base64 string. The tool applies the reverse process: it decodes the Base64 characters back to bytes, then interprets those bytes as UTF-8 text using the TextDecoder API.

If the input contains characters that are not valid Base64 (such as !, @, or #), the tool will display an error rather than produce incorrect output. In that case, check that the string was not accidentally truncated or corrupted, and verify whether you need the URL-safe variant.

How to Encode Files to Base64

The File tab accepts any file — images, PDFs, audio, video, binaries, or text files. Drag and drop a file onto the drop zone, or click to browse. The file is read locally using the FileReader API; nothing is uploaded to any server.

The tool reads the file as raw binary data (an ArrayBuffer) and converts it to a Base64 string. You can optionally enable the Include data URI prefix option, which prepends the MIME type like:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...

This format can be used directly in HTML:

<img src="data:image/png;base64,iVBORw0KGgo..." alt="Embedded image" />

Or in CSS:

background-image: url("data:image/svg+xml;base64,PHN2ZyB...");

Base64 in Programming Languages

Here is how to encode and decode Base64 in the most common languages:

JavaScript (Browser & Node.js)

// Encode (handles Unicode)
const encoded = btoa(String.fromCodePoint(
  ...new TextEncoder().encode("Hello, World!")
));
// "SGVsbG8sIFdvcmxkIQ=="

// Decode (handles Unicode)
const decoded = new TextDecoder().decode(
  Uint8Array.from(atob(encoded), c => c.codePointAt(0))
);
// "Hello, World!"

In Node.js, use the Buffer API:

Buffer.from("Hello, World!").toString("base64");
Buffer.from("SGVsbG8sIFdvcmxkIQ==", "base64").toString("utf-8");

Python

import base64

encoded = base64.b64encode(b"Hello, World!").decode()
# "SGVsbG8sIFdvcmxkIQ=="

decoded = base64.b64decode(encoded).decode()
# "Hello, World!"

# URL-safe variant
base64.urlsafe_b64encode(b"Hello, World!").decode()

Java

import java.util.Base64;

String encoded = Base64.getEncoder().encodeToString("Hello, World!".getBytes());
// "SGVsbG8sIFdvcmxkIQ=="

byte[] decoded = Base64.getDecoder().decode(encoded);
// "Hello, World!"

// URL-safe variant
Base64.getUrlEncoder().withoutPadding().encodeToString("Hello, World!".getBytes());

Command Line (Linux / macOS)

echo -n "Hello, World!" | base64
# SGVsbG8sIFdvcmxkIQ==

echo "SGVsbG8sIFdvcmxkIQ==" | base64 --decode
# Hello, World!

Common Use Cases for Developers

API authentication: Many APIs use Base64 to encode credentials in the Authorization header — for example, HTTP Basic Auth sends username:password encoded as Base64.

JWT inspection: JWTs consist of three Base64url-encoded segments separated by dots. Paste a JWT into the Decode tab (and switch to URL-safe) to read the header and payload claims.

Embedding small assets: For small images, icons, or inline SVGs, embedding them as Base64 data URIs eliminates an HTTP request, which can improve performance for above-the-fold content. As a rule of thumb, Base64-embed assets under 10 KB — larger files are better served as separate requests.

Clipboard and export: When a binary value (such as a file hash, public key, or UUID) must be stored in a text file or config, Base64 provides a compact, copy-pasteable representation.

Debugging binary protocols: When working with binary wire formats (Protobuf, MessagePack, TLS), Base64 lets you inspect or log byte sequences in a readable form.

Email attachments (MIME): The MIME standard uses Base64 to encode binary file attachments within email messages, which are fundamentally text-based (RFC 2045).

Edge Cases and Gotchas

Unicode and btoa() failures: The browser’s native btoa() throws InvalidCharacterError on any character outside the Latin-1 range. If you try btoa("日本語") in the console, it crashes. This tool handles it correctly by converting to UTF-8 bytes first via TextEncoder — but be aware that many online tools and code snippets don’t, and will silently produce wrong output or throw.

Line breaks in Base64 strings: MIME-encoded Base64 (RFC 2045) inserts a line break every 76 characters. If you paste MIME-formatted Base64 into a decoder that expects a continuous string, it may fail. This tool strips whitespace automatically before decoding.

Padding ambiguity: Some systems strip = padding from Base64 output (common in JWTs and URL-safe contexts). Other systems require it. If decoding fails, try adding = or == to the end of the string to restore the expected 4-character alignment.

Newline at end of input: Running echo "test" | base64 on the command line encodes “test\n” (with a trailing newline), not “test”. This produces dGVzdAo= instead of dGVzdA==. Use echo -n "test" | base64 to avoid the extra newline. This tool does not add trailing newlines.

Large files and memory: Base64 encoding a 100 MB file produces ~137 MB of text. The browser can handle this, but copying 137 MB to the clipboard may freeze the tab. For files over 10 MB, consider using the command line instead.

Frequently Asked Questions

Is Base64 the same as encryption? No. Base64 is reversible encoding, not encryption. Anyone who sees a Base64-encoded string can decode it instantly. If you need to protect data, use proper encryption such as AES-GCM. Base64 is used only to make binary data safe for text environments.

Why does the Base64 output end with == or =? Base64 encodes 3 input bytes into 4 output characters. When the input length is not a multiple of 3, the output is padded with = characters to fill the final 4-character group. Two equals signs (==) means 1 remainder byte; one equals sign (=) means 2 remainder bytes.

What is the size overhead of Base64? Every 3 bytes of input produces 4 Base64 characters, so Base64 output is ⌈n/3⌉ × 4 characters long — approximately 33.3% larger than the original. For example, a 1 MB file becomes about 1.37 MB in Base64.

Can I use Base64 for passwords? No. Encoding is not hashing. Passwords should be stored as salted hashes using a purpose-built algorithm such as bcrypt, Argon2, or scrypt — never stored in Base64 or any other reversible encoding.

What is the difference between Base64 and Base64url? Both encode binary data into ASCII text. Standard Base64 uses + and / and pads with =. Base64url (RFC 4648 §5) replaces + with - and / with _, and typically omits padding. Use Base64url when the encoded string will appear in URLs, query parameters, file names, or JWTs.

How do I Base64-encode a file from the command line? On Linux or macOS, use base64 < file.png. On Windows with PowerShell, use [Convert]::ToBase64String([IO.File]::ReadAllBytes("file.png")). The output can then be pasted into data URIs or config files.

Is my data private when using this tool? Yes. All encoding and decoding happens in your browser using native JavaScript APIs (TextEncoder, TextDecoder, btoa, atob, and FileReader). No data is ever sent to a server. Files are processed entirely locally.

Related Tools

More Encoding & Crypto Tools