Direction

Enter something to see the result.

Every conversion runs in your browser. Nothing you paste here is sent anywhere.

How it works

Base64 is not encryption. It is a way of writing binary data using 64 characters that survive channels which only accept text — email, JSON, URLs. Anyone can reverse it in a second, so it hides nothing.

It works in groups: three input bytes become 24 bits, split into four groups of six, each looked up in a 64-character table. That is why the output is always about a third longer than the input. When the byte count is not a multiple of three, the shortfall is marked with one or two `=` characters at the end.

The detail that matters most: the browser’s built-in `btoa` operates on Latin-1 and throws `InvalidCharacterError` on any character above U+00FF — which is to say, on the first accented letter it meets. This page encodes text to UTF-8 bytes with `TextEncoder` first, so "Xin chào" round-trips intact.

Base64URL is the variant used in URLs and in JWTs: `+` and `/` become `-` and `_`, and the padding is dropped. Feeding a Base64URL string to a plain Base64 decoder fails on the first `-`, which is why these are two separate modes rather than one.

Formula

Base64 length = ⌈byte count ÷ 3⌉ × 4

Always a multiple of four, and about 33% longer than the input. A valid Base64 string is never a length that leaves a remainder when divided by four — the cheapest way to reject a corrupted one.

Worked example

Encoding "Chào":

Text
Chào
UTF-8 bytes
43 68 C3 A0 6F — five bytes, not four
Base64
Q2jDoG8=
Calling btoa directly
InvalidCharacterError

"à" occupies two bytes in UTF-8, and it is that byte which makes `btoa` throw. Converting to bytes first is required, not optional.

Frequently asked questions

Is Base64 encryption?

No. It is a representation, reversible by anyone with no key. Never use it to protect passwords, API keys or personal data.

Why do Base64 strings end in =?

That is padding. Base64 works in groups of three bytes; when the last group is short, one or two `=` tell the decoder how many bits to discard.

What is the difference between Base64 and Base64URL?

Base64URL swaps `+` for `-`, `/` for `_`, and drops the `=`, so the string can sit in a URL without percent-encoding. It is the form used in JWTs and most path-borne tokens.

How is URL encoding different?

URL encoding replaces only the characters that are unsafe in a URL with %XX and leaves the rest readable. Base64 transforms everything into an unreadable string. Use URL encoding for query parameters, Base64 for binary data.

Why does decoding say "not valid UTF-8"?

The string decoded to valid bytes, but those bytes are not text — usually an image, a binary key, or a string that was truncated. This tool reports the error instead of returning a run of replacement characters that would look like a successful decode.

Is what I paste sent anywhere?

No. Every conversion runs in your browser. This site is a set of static files with no server to receive it.

Sources

Report a problemWrong result, out-of-date figures or a display bug? Send it from here. The page address and tool name are attached for you — just describe what is wrong.

Report a problem

The more specific the faster it gets fixed: what you entered, what you got, and what you expected.

What kind of problem?
0/2000

Only used to reply to you, nothing else.

Sent with your report

Page
/en/base64-encoder
Tool
Base64 & URL Encoder
Language
English

The values you typed into the tool are not sent. Besides what is listed below, the server records the browser type and uses your IP address to rate-limit submissions — the privacy policy has the detail.