Home / Converters

Base64 Encoder and Decoder

Runs locally in your browser. Your input is not uploaded.

A Base64 encoder converts bytes into a text representation suitable for systems that expect text. A decoder reverses the process. Use this tool to inspect encoded messages, prepare sample payloads, or troubleshoot integrations while keeping character encoding and security limits in view.

How to Use the Base64 Encoder and Decoder

Convert UTF-8 text or inspect a Base64 value as you type.

  1. Choose Encode or Decode with the mode toggle.
  2. Select URL-safe (Base64url) when the source or destination expects that variant.
  3. Type or paste the input; output updates live, and text input is treated as UTF-8.
  4. Select Swap to move the output into the input and flip the mode.
  5. Select Copy to copy the current output.

What is Base64 Encoding and How Does it Work?

Base64 represents binary data using a limited alphabet of printable characters. Standard Base64 uses letters, digits, +, and /, with = padding where required by the format. It processes three input bytes into four output characters, so the encoded result is roughly one-third larger for large inputs.

For example, the UTF-8 bytes for Hello become SGVsbG8=. Decoding recovers those original bytes. Whether the recovered data is readable text depends on what was encoded.

For multilingual text, convert characters to UTF-8 bytes before encoding. Passing arbitrary Unicode directly to browser btoa() can fail because it expects a binary string. The reverse operation must also decode bytes using the correct character encoding.

Base64url uses - and _ instead of + and /, and some protocols omit padding. Select the variant expected by the receiving system rather than replacing characters without understanding the format.

Base64 vs. Encryption: Understanding the Security Differences

Base64 is reversible encoding, and decoding does not require a secret. Anyone who receives the string can recover the original data. It is suitable for representation and transport, but it provides no confidentiality or proof that the content is authentic.

Encryption protects data using cryptographic keys. Hashing produces a digest for a different purpose, such as comparison or integrity checking. These operations solve separate problems and should not be substituted for one another.

For example, placing username:password into a Base64 string does not protect those credentials. The surrounding protocol still needs appropriate transport security and credential handling. Likewise, an encoded API key remains an API key and should be treated as sensitive.

If you need a SHA-256 or SHA-512 digest, use the hash generator. If you are inspecting the readable parts of a signed token, use the JWT decoder and remember that decoding does not verify trust.

Common Use Cases for Base64 in Frontend Architecture (Data URIs, Webhooks)

Base64 can carry small binary assets inside a data URI, such as an image embedded directly into a document. This can simplify a self-contained example, but the larger representation and loss of independent resource caching make it a poor default for large images.

Integrations may also place binary content into a JSON property using Base64. A webhook containing an encoded attachment is one example, although many webhooks use ordinary JSON without Base64 at all. Follow the provider's schema rather than assuming every opaque field is encoded content.

When debugging, identify the full chain: original bytes, encoding variant, JSON escaping, and any transport-specific transformations. An unexpected line break or a + interpreted as a space in form data can break decoding.

Use Base64 where a text-only interface requires it. For ordinary downloads, a binary response or separate asset URL is often a better fit.

How to Safely Decode Unknown Base64 Strings

Decode unknown strings as data. Do not execute decoded JavaScript, inject decoded markup into the page, or automatically open recovered URLs. A string that passes Base64 validation can still contain malicious content.

First, check whether the source expects standard Base64 or Base64url. Then decode to bytes and inspect a bounded preview. Invalid UTF-8 may mean the content is binary rather than corrupted text; avoid silently replacing bytes if exact recovery matters.

Large inputs can consume significant memory because the browser may hold the encoded string, decoded bytes, and displayed text simultaneously. Use conservative size limits, especially on mobile devices.

If decoding reveals JSON, inspect it with the JSON formatter. If it reveals a credential or token, keep it out of screenshots, shared documents, and diagnostic logs. Redact real values before asking another person to help.

Frequently Asked Questions

Is Base64 encryption?

No. Base64 is an encoding that represents bytes with printable characters, and anyone can reverse it without a password or key. It does not provide confidentiality, integrity, or authentication. Use established encryption for secret data, secure transport for data in transit, and a purpose-built password hashing algorithm when storing passwords.

Why does Base64 sometimes end with equals signs?

Standard Base64 processes input in groups of three bytes and produces groups of four characters. One or two = characters can pad the final group when the input length is not divisible by three. Some protocols, especially Base64url profiles, omit padding, so whether it is required depends on the receiving specification and decoder.

What is the difference between Base64 and Base64url?

Base64url replaces the standard + and / characters with - and _, making the result easier to use in URLs and filenames. Some Base64url contexts also omit trailing = padding. The underlying byte representation is closely related, but the variants are not always accepted interchangeably by strict decoders.

Why does decoded Base64 look unreadable?

Base64 can represent any bytes, not only text. Unreadable output may be an image, compressed data, encrypted content, or text encoded with a character set other than UTF-8. It can also indicate the wrong Base64 variant or damaged input. Identify the expected content type before treating replacement characters as proof of corruption.

Can Base64 encode emoji and non-English text?

Yes, when the text is first converted to bytes with a character encoding such as UTF-8. This tool treats text as UTF-8, so emoji and multilingual characters can round-trip correctly. Problems arise when another system encodes or decodes the same Base64 bytes using a different character set or passes Unicode directly to a byte-only API.

References: RFC 4648: Base-N Encodings · MDN: btoa() and Unicode handling.