Base64 Encoder and Decoder

Encode text to Base64 or decode Base64 back to text. UTF-8 is handled correctly for Nepali, Hindi and emoji, with URL-safe and data-URI output. Nothing is uploaded.

Free, no account, and it runs on your device

Use URL-safe for query strings and tokens. The data URI can be pasted straight into HTML or CSS.

How to encode or decode Base64

  1. Choose Encode to turn text into Base64, or Decode to turn Base64 back into text.
  2. Paste into the first box. Line breaks and spaces in Base64 input are ignored, so wrapped output from email or a log file works as-is.
  3. Pick a variant when encoding: standard, URL-safe, or a full data URI.
  4. Press Convert, then copy the result. Switch direction with Use result as input to check a round trip.

What Base64 actually does

Base64 converts arbitrary bytes into 64 printable characters: A–Z, a–z, 0–9, plus two more (usually + and /). Every three bytes become four characters, using the alphabet defined in RFC 4648. The point is to move binary data through channels that only accept text — an email body, an HTTP header, a JSON field, a URL, a CSS file.

The 64 characters are chosen because they survive nearly every transport: they are not control codes, not whitespace, and not characters that protocols treat specially. The cost is size. Three bytes become four characters, so any payload grows by about a third, and small payloads grow proportionally more because of padding.

Base64 is not encryption

This is the mistake that leaks data. Encoding is reversible by design and needs no key; a decoder is one line of code. If a value is sensitive in its original form, it is exactly as sensitive after Base64. Passwords, API keys, session tokens and personal data should be encrypted or not transmitted, not merely encoded.

Basic authentication is the classic case that confuses people. The Authorization: Basic … header is only Base64, which means the username and password are readable by anyone who can see the request. It is safe only under TLS, and only because the connection is encrypted — not because of the encoding.

UTF-8, and why some tools corrupt Nepali text

Base64 encodes bytes, so the text has to be turned into bytes first. The browser function btoa() takes one byte per character and throws on anything above U+00FF. Many quick tools catch that error and strip the high bits, which turns a Nepali word into mojibake that still looks like valid Base64.

This page encodes UTF-8, the same encoding JSON, HTML, HTTP and almost every API use. A Devanagari letter takes three bytes, so नमस्ते is 18 bytes and encodes to 4KSo4KSu4KS44KWN4KSk4KWH. Decoding that string here returns the original text, conjuncts and all. Emoji are four bytes each but still round-trip correctly.

The three variants you will meet

VariantAlphabetPaddingWhere it appears
Standard+ and /=Email attachments (MIME), JSON fields, most APIs
URL-safe- and _usually omittedJWT, OAuth state, query strings, filenames
Data URIstandard inside a prefix=<img src>, CSS url(), small icons

A data URI looks like data:text/plain;base64,SGVsbG8=. The prefix declares the media type, and the browser decodes the rest. It is a neat way to inline a tiny icon without another request, but a poor way to embed a photo: the text is 33% larger than the file, cannot be cached on its own, and blocks the CSS or HTML that carries it.

Common uses

  • API payloads — carrying a small binary value, a signature or a key inside JSON.
  • Email — MIME encodes attachments so they survive text-only mail servers.
  • Tokens — JWT header, payload and signature are URL-safe Base64 joined by dots.
  • Embedding — icons and fonts inside CSS for offline or single-file pages.
  • Debugging — reading the payload of a token or a header you were handed.

Reading the result

When decoding, the tool reports how many bytes the string produced and warns if the bytes are not valid UTF-8 text. That warning is useful: it usually means the Base64 belongs to an image, a PDF or an encrypted blob, not to a sentence. Binary data often decodes to replacement characters (�), which look like broken text but are simply bytes that have no character meaning.

Invalid input is rejected with the specific reason — a character outside the alphabet, or a length that cannot be valid. A length of one more than a multiple of four is the usual sign that a string was truncated when copied.

Privacy

Encoding and decoding happen in your browser. Nothing is uploaded and nothing is stored, which is the point when the input is a token or a header you would rather not paste into a server-side tool. The page works offline once loaded.

Related tools: format and validate JSON (the format that usually carries Base64 values), generate a QR code, or count characters before a field hits its limit.

Questions people ask

Is Base64 encryption?

No. It is a reversible encoding: anyone can decode it in one step, with no key. Treat Base64 text exactly like the original — never as protection for a password, a token or a private note. If you need secrecy, use encryption and then, if necessary, encode the ciphertext.

Why do some Base64 strings end with = or ==?

Base64 works in groups of three bytes, which become four characters. When the last group has only one or two bytes, the missing characters are filled with = so the length stays a multiple of four. One = means one missing byte, two means two. Decoders accept input without the padding, and the URL-safe variant usually drops it.

What is URL-safe Base64?

Standard Base64 uses + and /, which have meaning inside a URL and in a query string. The URL-safe variant, defined in RFC 4648 §5, swaps them for - and _ and drops the padding. JWTs, for example, use exactly that alphabet for their three parts.

Why does my Base64 look wrong for Nepali or emoji?

Because the bytes matter, not the characters. A correct tool encodes the UTF-8 bytes: नमस्ते is 18 bytes and starts with 4KSo. A tool built on the browser's btoa() encodes one byte per character and silently corrupts anything above U+00FF. This page always uses UTF-8, which is also what JSON, HTML and APIs expect.

How much larger does Base64 make my data?

About 33% larger: every three bytes become four characters. A 1 MB image becomes about 1.37 MB of text. That overhead is why Base64 is used for transport and embedding, not for storage.

Can I decode a Base64 image or PDF here?

The decoder gives you bytes and tells you when they are not valid UTF-8 text, so you can see that you have a file rather than text, but this page does not rebuild the file. For images, the common use is a data URI embedded in CSS; decode it with a dedicated tool that restores the binary.

Updated · 28 Kartik 2083 BS