Skip to content
koducathome

Base64 Encoder & Decoder

Encode text to Base64 or decode Base64 to text, with full UTF-8 support and a URL-safe Base64url option.

How to use this tool

Steps for using the Base64 Encoder.

  1. Choose Encode to turn text into Base64, or Decode to turn Base64 back into text.
  2. Type or paste into the input panel — the result updates as you type. Click Sample for an example.
  3. When encoding, tick URL-safe Base64url to get output with - and _ and no = padding, suitable for URLs, filenames and JWTs.
  4. To encode a file (up to 5 MB), click Encode a file; the output is a data: URI you can paste into HTML or CSS, or plain Base64 if you untick the option.
  5. If decoded bytes are not valid UTF-8 text, the tool shows a hex dump instead and lets you download the raw bytes with Download .bin.
  6. Use Use output as input to reverse the operation, then Copy or Download the result.

Example

Encode text

Text
Hello, World!
Base64
SGVsbG8sIFdvcmxkIQ==

Common use cases

  • Building an HTTP Basic Authorization header (Basic + Base64 of user:password).
  • Inspecting the header and payload of a JWT by hand — or use the JWT Decoder for a structured view.
  • Embedding small images or fonts in HTML and CSS as data: URIs.
  • Reading Base64 values from Kubernetes Secrets, environment variables or API responses.
  • Checking whether a mysterious Base64 blob is text or binary before processing it.

How Base64 encoding works

Base64 represents binary data using 64 printable ASCII characters: A–Z, a–z, 0–9, + and /. Every 3 input bytes (24 bits) are split into four 6-bit groups, and each group selects one character. When the input length is not a multiple of three, the last group is padded with one or two = signs. The result is always about 33% larger than the input, which is the price for surviving systems that only handle text — email bodies, JSON strings, HTTP headers and HTML attributes.

Base64 works on bytes, not characters, so text must first be converted to bytes. This tool uses UTF-8 via TextEncoder, which is what virtually every API expects. That matters because the browser's built-in btoa() only accepts Latin-1 characters and throws on anything else — btoa("€") fails, whereas the UTF-8 encoding of € is three bytes that encode cleanly to 4oKs.

Base64url (RFC 4648 §5) swaps + for - and / for _ so the output can appear in URLs and filenames without percent-encoding, and it usually drops the = padding. JSON Web Tokens use it for all three segments. The decoder here accepts both alphabets, ignores spaces and line breaks (as found in PEM files and MIME bodies), tolerates missing padding, and strips a leading data:…;base64, prefix.

Decoding is strict about everything else. Characters outside the Base64 alphabets are reported with their position, = in the middle of the data is rejected, and a length that cannot correspond to whole bytes is flagged. After decoding, the bytes are checked with a fatal UTF-8 decoder: if they are not valid text — an image, a gzip stream, encrypted data — you get a warning and a hex dump rather than a screen of replacement characters.

Limitations

  • Base64 is an encoding, not encryption: anyone can decode it. Never use it to protect secrets.
  • File encoding is limited to 5 MB, and text input to 2 million characters, to keep the page responsive.
  • Text is always encoded as UTF-8; other character sets such as UTF-16 or Windows-1252 are not offered.
  • The hex view shows the first 64 KB of binary output; download the .bin file for the complete data.

Frequently asked questions

Why does my decoded text look garbled?

Either the data is binary rather than text, or it was encoded from a non-UTF-8 character set. The tool warns you and switches to a hex view when the bytes are not valid UTF-8, so you can see what they actually contain.

What is the difference between Base64 and Base64url?

Only two characters and the padding: Base64url uses - and _ instead of + and /, and normally omits =. Both encode the same bytes. The decoder accepts either form, so you never need to convert before decoding.

Why do I get "Invalid character" errors?

The input contains something outside both Base64 alphabets — often a stray quote, a % from URL-encoding, or a character copied from rich text. The error message names the character and its position, for example Invalid character '@' at position 8.

Are my files uploaded when I encode them?

No. Files are read locally with the browser's File API and never leave your device. The same applies to everything you type.

Is Base64 the same as URL encoding?

No. Base64 re-encodes arbitrary bytes into a 64-character alphabet; percent-encoding escapes individual unsafe characters in a URL and leaves the rest readable. For URLs use the URL Encoder.