πŸ€–NEW:AI-Powered Incremental Builds β€” your site updates in under 30 seconds. See what's new β†’
Developer Utility Β· 100% Client-Side

Base64 Encoder & Decoder

Encode text to Base64 or decode Base64 back to plain text. Supports standard and URL-safe modes. Zero uploads β€” runs entirely in your browser.

Output appears here…
Technical Guide

How Base64 Encoding & Decoding Works

1. What This Tool Actually Does

This tool converts text to and from Base64 entirely with your browser's built-in btoa() and atob() functions. In Encode mode, it first runs your input through encodeURIComponent() and re-maps the percent-escaped bytes into raw characters before calling btoa() β€” this extra step is what lets the tool correctly encode Unicode text (accented letters, emoji, non-Latin scripts), which the plain btoa() function cannot handle on its own. In Decode mode it reverses the process: atob() turns Base64 back into raw bytes, and decodeURIComponent() reassembles those bytes into the correct Unicode string.

The URL-safe toggle switches the output alphabet: standard Base64 uses + and /, which have reserved meaning inside URLs, so URL-safe Base64 substitutes - and _ instead and drops the trailing = padding characters. When decoding, the tool reverses these substitutions before calling atob().

2. How to Use the Base64 Encoder/Decoder

  1. Choose Encode or Decode using the mode toggle at the top.
  2. Toggle URL-safe on if the string needs to travel inside a URL, query parameter, or filename β€” leave it off for standard Base64 used in HTTP headers, JSON, or data URIs.
  3. Type or paste your text into the left panel. The output updates instantly on every keystroke.
  4. If you're decoding, a red Error badge appears with a specific message if the string has invalid characters or broken padding.
  5. Use ⇄ Swap to move the current output into the input box and flip modes β€” handy for verifying a round-trip encode/decode.
  6. Click Copy to copy the result, and check the stats row for input/output character counts and size overhead.

3. How Base64 Actually Works

Base64 is a binary-to-text encoding: it takes raw bytes and represents them using only 64 printable ASCII characters (A–Z, a–z, 0–9, plus two symbols) so the result is guaranteed safe to place inside text-only channels β€” JSON strings, XML, email headers, or URLs β€” that would otherwise choke on arbitrary binary bytes. It works by grouping input into 3-byte (24-bit) chunks and re-splitting each chunk into four 6-bit values, each of which maps to one character in the Base64 alphabet. Because 6 bits can only represent 64 distinct values, and a byte is 8 bits, encoding always expands the data β€” every 3 input bytes become exactly 4 output characters, a fixed 4:3 size increase, or roughly +33% overhead. When the input isn't a clean multiple of 3 bytes, the final group is padded with = characters so the decoder knows how many of the last 4 characters represent real data.

4. Real Examples

Encoding the ASCII string Hello, World! produces:

SGVsbG8sIFdvcmxkIQ==

With URL-safe mode on, the two trailing = padding characters are stripped (this string happens to contain no + or /, so nothing else changes): SGVsbG8sIFdvcmxkIQ.

Now try a string with a non-ASCII character, cafΓ©. The "Γ©" is encoded as two UTF-8 bytes before Base64 runs, producing:

Y2Fmw6k=

Paste either value back into Decode mode and you'll get the exact original string back β€” this round-trip is exactly what the ⇄ Swap button lets you verify with one click.

5. Practical Use Cases

  • HTTP Basic Authentication: The Authorization: Basic header requires username:password to be Base64-encoded before it's sent β€” useful when testing an API with curl or Postman by hand.
  • Inline data URIs: Small icons or fonts embedded directly in CSS as background-image: url(data:image/png;base64,...) to avoid an extra HTTP request.
  • Debugging JWTs: Paste the header or payload segment of a JSON Web Token (with URL-safe enabled) to decode the raw JSON and inspect claims during API debugging.
  • Embedding binary in JSON APIs: Many REST APIs transport small binary blobs (signatures, thumbnails, encryption IVs) as Base64 strings inside JSON, since JSON has no native binary type.
  • WordPress webhook payloads: Some plugin integrations Base64-encode webhook secrets or signed payloads β€” this tool lets you inspect them without writing a script.

6. Common Mistakes & Limitations

  • Mixing up standard and URL-safe alphabets: A URL-safe string decoded with URL-safe turned off (or vice versa) fails because -/_ aren't valid standard Base64 characters. Match the mode to how the string was originally produced.
  • Treating it as security: Base64 is not encryption. Anyone can decode it in one click β€” never rely on it to hide passwords, API keys, or personal data.
  • Missing or incorrect padding: A hand-edited Base64 string with the wrong number of trailing = characters will throw a decode error β€” the tool's error message will call out incorrect padding specifically.
  • Overusing data URIs for large images: Because encoding adds ~33% overhead and inlined data can't be cached separately by the browser, Base64-embedding large images actually hurts page weight and repeat-visit performance β€” reserve it for genuinely small, frequently-reused assets like icons.

Frequently Asked Questions

What is Base64 encoding?

Base64 is a binary-to-text encoding scheme that represents binary data as a string of ASCII characters. It uses 64 characters (A-Z, a-z, 0-9, +, /) to encode any data, making it safe to embed in JSON, XML, HTML attributes, URLs, and email headers.

What is URL-safe Base64?

Standard Base64 uses + and / which have special meaning in URLs. URL-safe Base64 replaces + with - and / with _ so the encoded string can be used safely in URL query parameters and HTTP headers without percent-encoding.

Does my data leave my browser?

No. All encoding and decoding is done entirely in your browser using the built-in btoa() and atob() functions. Nothing is uploaded to any server.

When is Base64 used in WordPress/web development?

Common uses include: embedding small images as data URIs in CSS/HTML, encoding credentials in HTTP Basic Auth headers, passing binary data in JSON payloads, storing small binary blobs in databases, and encoding font files inline in stylesheets.

Is Base64 the same as encryption or compression?

No. Base64 is neither. It is a reversible encoding scheme with no secret key β€” anyone can decode a Base64 string back to its original form instantly, so it provides zero confidentiality. It also makes data larger, not smaller (roughly +33%), so it is not a compression technique either. Never use Base64 alone to "protect" sensitive data like passwords or tokens.

Why does my encoded output end with = or ==?

Base64 encodes input in 3-byte chunks into 4 characters. When the input length isn't a multiple of 3, the last chunk is padded with one or two = characters to keep the output length a multiple of 4. Standard mode keeps this padding; URL-safe mode in this tool strips it, since most modern decoders can infer it from length.

How does Base64 relate to JWT (JSON Web Tokens)?

A JWT has three dot-separated parts β€” header, payload, and signature β€” and the first two are JSON objects encoded with Base64URL (the same URL-safe alphabet this tool supports, with padding stripped). You can paste a JWT's header or payload segment into Decode mode with URL-safe enabled to inspect its raw JSON.