base64 encode & decode online

Encode or decode text with base64. No key needed, fully reversible, and nothing leaves your browser.

Runs in your browser
How it works

Base64 step by step: 3 bytes become 4 characters

Base64 reads your text as bytes, three at a time. Those 24 bits are cut into four pieces of 6 bits; each piece is a number from 0 to 63 and picks one of the 64 characters. If the last group is short, zero bits fill it up and = stands in for the missing characters.

h01101000e01100101l01101100
a011010 = 26G000110 = 6V010101 = 21s101100 = 44
l01101100o01101111␣00100000
b011011 = 27G000110 = 68111100 = 60g100000 = 32
w01110111o01101111r01110010
d011101 = 292110110 = 549111101 = 61y110010 = 50
l01101100d01100100–no byte
b011011 = 27G000110 = 6Q010000 = 16=padding

11 bytes in, 16 characters out: +45 %

Typing in the tool above fills this in. Nothing leaves your browser.

In short

What is Base64?

Base64 turns any bytes into text made of 64 safe characters (A–Z, a–z, 0–9, + and /), so binary data survives e-mail, JSON, XML and URLs. Every 3 bytes become 4 characters, which makes the result about 33 % larger; = fills up the last group. It is defined in RFC 4648 and is not encryption: anyone can decode it.

Not encryptionAnyone can decode it, no key needed. It changes the format, not who can read it. Encoding vs hashing vs encryption →
Where you meet it
  • Data URIs for images in HTML and CSS
  • E-mail attachments (MIME)
  • HTTP Basic Auth headers
  • JSON Web Tokens (as base64url)
  • Kubernetes secrets
  • PEM keys and certificates
Check & decode

Why won't my Base64 decode?

Paste what you have. The check tells you what is wrong, what kind of data is inside and shows the decoded result, including images and files.

Examples:
  • Paste text above or try an example.
Every form at once

Standard, URL-safe, MIME and data URI

The same input in the forms you meet in practice. Shown for hello world; type in the box above or in the tool to use your text.

Standard (RFC 4648)what the tool returns
aGVsbG8gd29ybGQ=
URL-safe (base64url)- and _ instead of + and /, no =
aGVsbG8gd29ybGQ
Without paddingsome APIs drop the =
aGVsbG8gd29ybGQ
MIME (76 per line)like chunk_split(); e-mail, PEM uses 64
aGVsbG8gd29ybGQ=↵
Data URIpaste into a browser or img src
data:text/plain;charset=utf-8;base64,aGVsbG8gd29ybGQ=
Use it in code

The same result in your code

Every snippet encodes hello world to aGVsbG8gd29ybGQ= exactly like the tool, then decodes it back. They are run and compared with the tool before each release.

PHP
echo base64_encode('hello world'), "\n";
echo base64_decode('aGVsbG8gd29ybGQ='), "\n";
Python
import base64

print(base64.b64encode("hello world".encode()).decode())
print(base64.b64decode("aGVsbG8gd29ybGQ=").decode())
Node.js
console.log(Buffer.from("hello world").toString("base64"));
console.log(Buffer.from("aGVsbG8gd29ybGQ=", "base64").toString());
Browser
const bytes = new TextEncoder().encode("hello world");
console.log(btoa(String.fromCharCode(...bytes)));

const back = Uint8Array.from(atob("aGVsbG8gd29ybGQ="), (ch) => ch.charCodeAt(0));
console.log(new TextDecoder().decode(back));

btoa() alone only handles Latin-1; going through TextEncoder makes it UTF-8 like the tool.

Java
import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class Enc {
  public static void main(String[] args) throws Exception {
    System.out.println(Base64.getEncoder().encodeToString("hello world".getBytes(StandardCharsets.UTF_8)));
    System.out.println(new String(Base64.getDecoder().decode("aGVsbG8gd29ybGQ="), StandardCharsets.UTF_8));
  }
}
Go
package main

import (
	"encoding/base64"
	"fmt"
)

func main() {
	fmt.Println(base64.StdEncoding.EncodeToString([]byte("hello world")))
	b, _ := base64.StdEncoding.DecodeString("aGVsbG8gd29ybGQ=")
	fmt.Println(string(b))
}
Command line
printf '%s' 'hello world' | base64
printf '%s' 'aGVsbG8gd29ybGQ=' | base64 -d

# Long input: base64 -w 0 (Linux) to avoid line breaks
# Windows: certutil -encode file.bin out.txt
Test values

Base64 examples and test values

What the tool returns for these inputs (UTF-8). Use them to check your own code. ↵ marks a line break.

InputBase64
empty stringempty
aYQ==
abYWI=
abcYWJj
hello worldaGVsbG8gd29ybGQ=
GrüßeR3LDvMOfZQ==
€4oKs
🙂8J+Zgg==
Common mistakes

Why your Base64 doesn't match

Base64 or base64url?

JWTs, many APIs and URLs use base64url: - and _ instead of + and /, usually without =. A standard decoder misreads or rejects it. The check panel tells you which one you have; base64url tool.

+ turned into a space

In a URL query a + means a space, so Base64 pasted into a URL loses its plus signs on the way. URL-encode it (%2B) or use base64url.

echo adds a line break

echo "hello" | base64 encodes six bytes, the text plus a line break, and gives aGVsbG8K. printf '%s' hello | base64 gives aGVsbG8=, the same as the tool.

Same text, different bytes

The tool encodes UTF-8 bytes. "ü" is c3 bc in UTF-8 but fc in Latin-1, so Base64 gives w7w= or /A==. If a decoded result shows ü instead of ü, the charsets got mixed up; fix garbled text.

Line breaks every 76 characters

GNU base64 wraps its output at 76 characters (use -w 0), MIME and PEM wrap too. PHP and most decoders ignore the breaks; strict ones like Java's Base64.getDecoder() reject them (use getMimeDecoder()).

btoa() fails on ü

JavaScript's btoa() only accepts characters up to U+00FF and throws on "ü" or emoji, or encodes Latin-1 instead of UTF-8. Turn the text into UTF-8 bytes first, as in the browser example above.

Missing = at the end

A Base64 string without padding has a length that is not a multiple of 4. PHP and browsers accept that, Python's b64decode() raises "Incorrect padding". Add = until the length is divisible by 4.

Encoding hides nothing

Anyone can decode it, no key needed. Kubernetes secrets, Basic Auth headers and "encoded" passwords in config files are readable by everyone who sees them. Use encryption to keep something secret.

FAQ

Questions about Base64

Is Base64 encryption?

No. Base64 has no key and anyone can decode it, here or with one line of code. It only makes bytes safe to send as text. To keep data secret, encrypt it first and Base64-encode the result.

Why does Base64 end with = or ==?

Base64 works in groups of 3 bytes. If the last group has only 1 or 2 bytes, it gets == or = so the length stays a multiple of 4. The step-by-step view above shows it with your text.

How much bigger does Base64 make data?

About a third: n bytes become 4 × ⌈n / 3⌉ characters, so 3 bytes become 4 and 1 MB becomes about 1.33 MB. With line breaks (MIME) it is a few percent more.

What is the difference between Base64 and base64url?

base64url uses - and _ instead of + and /, and usually drops the = padding, so the result can go into URLs and file names. JWTs use base64url. The bytes are the same.

How do I decode Base64 to an image or file?

Paste it into the check panel above. It recognises PNG, JPEG, GIF, WebP, SVG, PDF and ZIP, shows images directly and lets you save the file. Nothing is uploaded.

Good to know

Before you rely on it

Searches the list of pages on this site. What you type stays in your browser.