Skip to tool
ecech.
💻 Developer & Code

Free Online Base64 Encoder and Decoder for Text, Images and Any File

Text or files, both directions, with correct UTF-8 handling and a URL-safe toggle — plus the 33% size penalty shown before you paste a 4 MB image into a JSON payload.

Base64

Input size

0 B

Output size

0 B

Overhead

Detected type

text

Advertisement

How the calculation works

3 bytes in, 4 characters out — that is the whole idea 24 bits of input 01001101 01100001 01101110 regrouped into 6-bit chunks 010011 010110 000101 101110 looked up in the 64-char table T W F u Every 3 bytes become 4 characters, so the output is always about 33% larger. Base64 is not compression.

How to Use This Tool

Base64 exists because a lot of the internet was built assuming text. Email headers, JSON fields, XML attributes, URL parameters and CSS files all handle letters and digits reliably and choke on raw binary. Base64 converts arbitrary bytes into 64 characters that survive every one of those channels. What it does not do — despite being used this way constantly — is compress or secure anything.

Encoding and decoding

Choose a direction, then type or paste into the top box. The result appears below as you type. Two things this tool handles that a naive implementation gets wrong: UTF-8 and files. The browser's built-in btoa() throws an exception on any character above U+00FF, so a single accented letter or emoji breaks it. This tool encodes to UTF-8 bytes first, so "café" and "日本語" round-trip correctly. Use Load a file for images, PDFs or anything binary; the file is read locally and never uploaded.

The size penalty you should know about before you paste

Base64 takes every 3 bytes and produces 4 characters, which makes the output roughly 33% larger than the input, plus padding. This matters more often than people realise: inlining a 4 MB image as a data URI adds about 1.4 MB of pure overhead to your page, and embedding a large attachment in a JSON API request can push it past a gateway's payload limit for no functional benefit.

Original file 100 KB Base64 output +33% Gzip recovers some of it, but the encoded form still compresses worse than the original binary did.
Rule of thumb: encoded size ≈ original × 4 ÷ 3, rounded up to a multiple of 4. The tool shows the exact figures for your input.

URL-safe and wrapping options

Standard Base64 uses + and /, both of which have meaning inside a URL and get mangled by percent-encoding. The URL-safe toggle swaps them for - and _ and drops the = padding, which is the variant used by JWTs and most modern APIs. The wrap at 76 option inserts line breaks at the width MIME expects, which some older mail and certificate tools require and most modern parsers ignore.

What Base64 is not

It is not encryption and not obfuscation. Anyone can decode it instantly, including every automated secret scanner. Putting a password, API key or token in Base64 and treating it as hidden is a genuinely common and genuinely serious mistake. If the value needs protecting, it needs encryption; Base64 is only the envelope that lets encrypted bytes travel through a text channel.

Advertisement

Frequently Asked Questions

Why does Base64 make my file bigger?
Because it trades size for compatibility. Three bytes of input always become four output characters, since each character carries only six bits of information. That is a fixed 33% increase plus padding. Base64 is a transport encoding, not compression, and encoding something already compressed makes it larger with no benefit.
Why does my emoji or accented text break in other Base64 tools?
Most use the browser's btoa() directly, which only accepts characters below U+0100 and throws on anything else. This tool converts your text to UTF-8 bytes first and then encodes those bytes, so any Unicode character encodes and decodes correctly. Decoding reverses the same two steps.
Is Base64 a form of encryption?
No, and treating it as one is a serious mistake. It is a reversible public encoding with no key. Anyone can decode it in one command, and automated secret scanners decode it routinely. If something needs to stay secret, encrypt it — then Base64 the ciphertext if it must travel through a text-only channel.
When should I use the URL-safe alphabet?
Whenever the value goes into a URL path, query string, filename or JWT. Standard Base64 uses + and /, which have special meaning in URLs and get corrupted or double-encoded. URL-safe swaps them for - and _ and usually omits the = padding, which is what JWTs and most modern APIs expect.
Are my files uploaded to a server?
No. The file is read by your browser using the FileReader API and encoded locally in memory. There is no network request at any point, so you can safely encode confidential documents, private keys or customer data without them leaving your device.
Should I inline images as Base64 data URIs?
Only for very small assets — icons, tiny placeholders, a single-colour SVG. Below roughly 1 to 2 KB the saved HTTP request outweighs the 33% penalty. Above that you lose caching entirely, because an inlined image is re-downloaded with every page load rather than being cached separately.
What are the equals signs at the end for?
Padding. Base64 works on groups of three bytes; if the input length is not a multiple of three, one or two = characters mark how many bytes were missing from the final group. Some decoders require them and some do not, which is why the URL-safe variant that omits them occasionally causes interoperability problems.
Why did my decode fail with valid-looking Base64?
Most often the string contains whitespace or line breaks that were not stripped, has been URL-encoded so + became a space, or is URL-safe Base64 being fed to a standard decoder. This tool tolerates whitespace and detects the URL-safe alphabet automatically, and it names the specific problem when it still cannot decode.

What people usually need next

Picked by hand, not by algorithm.

Related tools in Developer & Code

Browse all Developer & Code tools