Free tool · no sign-up

Base64 Encoder / Decoder

Encode text to Base64 or decode Base64 back to readable text, with URL-safe mode for links and tokens. You can also turn a small image or file into a data URI. It all runs in your browser.

By Jamiul Alam Rejon · Updated

Everything runs in your browser. Nothing you type or upload is sent to a server.

Quick answer

Base64 is an encoding that turns any data into text using 64 characters (A–Z, a–z, 0–9, + and /). It works in groups of 3 bytes, which become 4 characters, so encoded data is about 33% larger. It's used for email attachments, data URIs and API tokens. It isn't encryption: anyone can decode it.

How does Base64 encoding work?

Computers store data as bytes of 8 bits. Base64 takes three bytes at a time (24 bits) and splits them into four groups of 6 bits. Six bits can hold a number from 0 to 63, and each number maps to one character in the Base64 alphabet. If the data doesn't divide into groups of three, the output is padded with one or two = signs.

H01001000i01101001!00100001
010010S000110G100100k100001h
Base64 takes 3 bytes (24 bits), cuts them into four 6-bit groups and maps each group to one of 64 characters. “Hi!” becomes “SGkh”.

Where Base64 is used

  • Data URIs: small images or fonts embedded straight into HTML or CSS, like data:image/png;base64,….
  • Email: attachments are Base64-encoded so they can travel through systems built for text.
  • APIs and auth: HTTP Basic auth sends username:password as Base64, and JSON Web Tokens use URL-safe Base64 for their parts.
  • Config and JSON: certificates, keys and binary values stored in text files.

Standard vs URL-safe Base64

StandardURL-safe
Characters 62 and 63+ and /- and _
Padding= at the endUsually removed
Used inEmail, data URIs, most APIsURLs, file names, JWTs

The decoder accepts both, so you can paste either kind.

How to encode and decode Base64 in code

JavaScript (browser)

// btoa/atob only handle Latin-1, so convert text to UTF-8 bytes first
const bytes = new TextEncoder().encode("Hi! ✓");
const b64 = btoa(String.fromCharCode(...bytes));

const back = new TextDecoder().decode(Uint8Array.from(atob(b64), (c) => c.charCodeAt(0)));

Node.js

Buffer.from("Hi!").toString("base64");        // "SGkh"
Buffer.from("SGkh", "base64").toString("utf8"); // "Hi!"

Python

import base64
base64.b64encode("Hi!".encode()).decode()   # 'SGkh'
base64.b64decode("SGkh").decode()           # 'Hi!'

Command line (macOS and Linux)

echo -n 'Hi!' | base64      # SGkh
echo 'SGkh' | base64 --decode

Should I embed images as Base64?

Only very small ones, like tiny icons. A Base64 image is about a third bigger than the file, can't be cached separately from the page, and makes your HTML or CSS heavier. For anything over a few kilobytes, a normal image file in a modern format like WebP or AVIF loads faster. Check page weight with the Website SEO Audit.

Frequently asked questions

What is Base64?

A way to write any data, including binary files, using only 64 safe text characters: A–Z, a–z, 0–9, + and /. It's used wherever a system only accepts text, such as email attachments, JSON, data URIs and HTTP headers.

Is Base64 encryption?

No. Anyone can decode it instantly, and there's no key. Never use Base64 to hide passwords, API keys or personal data.

Why is Base64 output longer than the input?

Every 3 bytes become 4 characters, so encoded data is about 33% larger, plus up to two = padding characters at the end.

What is URL-safe Base64?

A variant that replaces + with - and / with _, and usually drops the = padding, so the result can go in URLs and file names without escaping. JSON Web Tokens use it.

Does this tool handle emoji and non-English text?

Yes. Text is converted to UTF-8 bytes before encoding, so Bangla, Arabic, emoji and accented letters encode and decode correctly.

Is my data sent to a server?

No. Encoding and decoding happen in your browser with JavaScript. Nothing you type or upload leaves your device.