Skip to content

Base64 Encoder & Decoder

Convert text to Base64 and back, in either the standard or URL-safe alphabet. Unlike most converters, this one handles accents, emoji and non-Latin scripts correctly rather than crashing on them.

Runs in your browser · Files never uploaded
Direction
Alphabet

Standard Base64. Decoding accepts either alphabet automatically.

Base64 is an encoding, not encryption — anyone can reverse it. Converted on your device; nothing is sent anywhere.

How to use the Base64 converter

  1. Choose a direction — encode text to Base64, or decode Base64 back to text.
  2. Pick an alphabet when encoding. Standard for general use; URL-safe if the result goes into a URL or you are working with tokens.
  3. Paste your input. Conversion happens as you type.
  4. Copy the result, or use the swap button to feed it straight back through in the other direction.

Nothing is uploaded. All conversion happens in your browser.

When you would need this

Inspecting a JSON Web Token. JWT payloads are Base64URL encoded. Decoding one shows the claims, the expiry, and who issued it.

Reading a data URI. An embedded image or font in CSS or HTML is Base64. Decoding tells you what it actually is.

Building a Basic Auth header. The format is Authorization: Basic followed by username:password encoded as Base64.

Embedding a small asset. Inlining a tiny icon as a data URI removes an HTTP request, at the cost of about a third more bytes.

Moving data through a text-only channel. Email, older APIs and some configuration formats cannot carry raw binary. Base64 makes it survivable.

Why so many Base64 tools break on non-English text

This is worth explaining, because it is the single most common failure in online Base64 converters and it is entirely avoidable.

Browsers provide a built-in function called btoa(), and reaching for it is the obvious way to build one of these tools. The problem is what btoa actually expects: a string in which every character is a single byte — the Latin-1 range, U+0000 to U+00FF. Anything above that throws an InvalidCharacterError.

So btoa("hello") works. btoa("héllo") throws. btoa("日本語") throws. btoa("🎉") throws.

That is a large fraction of the world's text, and it fails at the first character outside a narrow Western European range. Tools built naively on btoa respond in one of three ways: they crash visibly, they catch the error and silently return nothing, or — worst — they pre-mangle the input with something like unescape(encodeURIComponent(...)) and produce output that decodes back to something different from what you put in.

The correct approach converts the text to UTF-8 bytes first, using TextEncoder, and encodes those bytes. UTF-8 represents every character as one to four bytes, all within the range btoa can handle. That is what this tool does, which is why héllo, 日本語, Ω≈ç√∫ and emoji all round-trip exactly.

You can verify it: encode something with an accent, decode it back, and confirm you get the original.

Base64 is not security

Worth its own section, because treating it as such causes real incidents.

Base64 has no key. It has no secret. It is a public, standardised, entirely reversible mapping between bytes and 64 printable characters. Decoding requires nothing but the willingness to decode.

Despite that, Base64-encoded values turn up regularly in places that clearly assumed otherwise: credentials in configuration files, API keys in client-side JavaScript, "obfuscated" values in URLs. Automated scanners look for Base64 strings precisely because they so often contain something interesting.

If a value needs to stay secret, it needs encryption with a key you control — and even then, the key has to live somewhere the attacker cannot reach. Base64 is transport, not protection.

The same applies to Basic Auth. Authorization: Basic dXNlcjpwYXNz is user:pass in plain view. It is only safe because HTTPS encrypts the connection carrying it, not because of the encoding.

Where the 64 characters come from

The name is literal: the encoding uses 64 characters, chosen because 64 is a power of two and every one of them survives systems that mangle anything unusual.

The standard alphabet is A–Z, a–z, 0–9, + and / — that is 26 + 26 + 10 + 2 = 64. Six bits of information fit exactly into one character, since 2⁶ = 64. Three bytes is 24 bits, which divides cleanly into four six-bit groups, which is why the encoding works in blocks of three input bytes to four output characters.

When the input is not a multiple of three, the final block is padded and = marks how much was added. One = means the last block held two bytes; two means it held one. The padding is not data — it exists so a decoder knows where the real content stopped.

The URL-safe variant swaps + for - and / for _, because the originals have meaning inside a URL: + can be read as a space in a query string, and / is a path separator. It also drops the padding, since = is reserved too. Everything else is identical, which is why a decoder can accept both without being told which it is looking at.

Limits and requirements

Decoding produces text. If the decoded bytes are not valid UTF-8 — a PNG, a PDF, any binary format — the tool says so rather than returning replacement characters. Use the image to Base64 tool for images.

Whole JWTs will not decode. The dots separating a token's three segments are not part of the Base64 alphabet. Decode one segment at a time. The signature segment is binary and will report as such.

Output is about 33% larger than input. Inherent to representing 256 byte values with 64 characters.

Very large inputs use memory. Both the input string and the encoded result are held at once. Multi-megabyte text will work but consume several times its own size while converting.

Browser support. Any modern browser on desktop or mobile.

Privacy: how this tool handles your text

Encoding and decoding run in your browser, on your device. Nothing is transmitted, logged or stored, and closing the tab discards everything.

This matters because of what Base64 is typically used for. Decoding a JWT means pasting a token that is very often still valid — anyone holding it can act as that user until it expires. Encoding a Basic Auth header means pasting a username and password in plain text. Decoding a data URI from a config file may reveal an embedded certificate or key.

A server-side converter receives all of that, and request bodies routinely end up in access logs, error trackers and backups without anyone intending it.

You can check this instead of trusting it. Open your browser's developer tools, switch to the Network tab, and convert something — nothing carries your input. Or disconnect from the internet after the page loads; it keeps working, because there is nowhere else for the work to happen.

Frequently asked questions

Why do other Base64 tools break on accented characters?

Because they use the browser's btoa() function directly, which only accepts characters in the Latin-1 range. Calling btoa('héllo') throws an error outright, and btoa('日本語') throws too. Many tools either crash, catch the error and return nothing, or mangle the text into something that will not decode. This tool converts text to UTF-8 bytes first with TextEncoder, then encodes those bytes — which is the correct approach and works for every language.

Is Base64 a form of encryption?

No, and this misunderstanding causes real security incidents. Base64 is an encoding — a reversible representation with no key and no secret. Anyone can decode it instantly, including with this page. It exists to carry binary data safely through systems that expect text, such as email or a URL. Never use it to hide a password, a token, or anything else that matters.

What is the URL-safe variant for?

Standard Base64 uses + and / and pads with =, all three of which have special meaning inside a URL and get mangled when a Base64 string is put in a query parameter or a path. The URL-safe alphabet, defined in RFC 4648 section 5, uses - and _ instead and drops the padding. It is what JSON Web Tokens use for each of their three segments. Decoding here accepts either alphabet automatically, so you do not need to know which you were given.

Why is the output about a third larger than the input?

Base64 represents every three bytes as four characters, which is a fixed 33% expansion, plus a little padding. That is the cost of the encoding, and it is unavoidable — you are representing 256 possible byte values using only 64 characters. It is why embedding images as Base64 data URIs makes them noticeably larger than the original file.

Can I decode a Base64 image or other binary file?

This tool decodes to text. If the decoded bytes are not valid UTF-8 — which is the case for a PNG, a PDF or any other binary format — it tells you so rather than returning replacement characters that look like a broken decode. For turning an image into a data URI, use the image to Base64 tool instead.

Do I need the padding characters at the end?

Standard Base64 pads with = so the length is a multiple of four. Many systems, including JWTs, strip that padding. This tool restores it automatically when decoding, so a string that lost its padding still works. When encoding, the standard alphabet includes padding and the URL-safe option omits it, matching what each is normally used with.

Is my text uploaded?

No. Encoding and decoding happen in your browser on your own device. Nothing is transmitted or stored. This is worth caring about because Base64 is frequently used with things that should stay private — decoding a JWT to inspect its claims means pasting a live session token, and encoding credentials for a Basic Auth header means pasting a password.

Why does my decoded JWT look like it is missing a piece?

A JWT has three dot-separated segments — header, payload and signature — and each is separately Base64URL encoded. Pasting the whole token will not decode, because the dots are not part of the alphabet. Paste one segment at a time. The third segment is a binary signature rather than text, so it will report as non-UTF-8, which is expected.

Written and maintained by Prashant ShekharLast updated