Encode · Developer

Base64 Encode / Decode

Convert text to Base64 and back — including URL-safe variants.

What is Base64 Encode / Decode?

The Base64 Encoder / Decoder converts text to and from Base64, including the URL-safe variant. Base64, defined in RFC 4648, represents binary data using 64 printable ASCII characters so it can travel safely through channels that expect text, such as email, JSON, and data URIs.

The tool is UTF-8 aware: it encodes text to bytes with the standard TextEncoder before Base64-encoding, so accented letters, emoji, and other multi-byte characters round-trip correctly. Standard Base64 uses + and / with = padding; the URL-safe option uses - and _ and drops padding.

Base64 is an encoding, not encryption. It provides no confidentiality — anyone can decode it. It runs entirely in your browser.

Why Use This Tool?

Many transports and formats only accept text. Base64 lets you embed binary or non-ASCII content — images in data URIs, tokens, small file blobs — inside text-only fields without corruption.

  • Embed binary safely in JSON, HTML, or URLs.
  • Handle UTF-8 text without mojibake.
  • Switch between standard and URL-safe alphabets.
  • Decode values you receive from APIs or tokens.

How Does This Tool Work?

To encode, the tool converts your text to UTF-8 bytes, then maps each group of three bytes to four Base64 characters using btoa on the binary string. For URL-safe output it replaces + with - and / with _ and strips trailing = padding.

To decode, it reverses URL-safe substitutions, restores padding to a multiple of four, decodes with atob, and interprets the resulting bytes as UTF-8. Invalid Base64 input produces a decode error.

Understanding Your Results

Encoded output is about one third larger than the input because every three bytes become four characters. Standard output may end with one or two = characters as padding; URL-safe output omits them.

If decoding fails, the input is not valid Base64 for the selected mode. A common mistake is decoding a URL-safe string in standard mode (or vice versa) — enable the matching option.

Why Tracking This Matters

Base64 is everywhere: JWT segments, data URIs, Basic auth headers, and binary fields in JSON. Understanding that it is reversible and offers no security prevents the common mistake of treating Base64 as if it hides sensitive data.

Benefits of Using Base64 Encode / Decode

  • Standard and URL-safe alphabets
  • Correct UTF-8 handling
  • Encode and decode in one place
  • Automatic padding restoration on decode
  • Clear encoding-not-encryption guidance
  • Fully in-browser processing

How Is the Result Calculated?

Base64 packs 3 input bytes (24 bits) into 4 output characters of 6 bits each. When the input length is not a multiple of three, padding = characters fill the final group. Encoded length is therefore approximately ceil(n / 3) × 4 characters for n input bytes.

encoded length ≈ ceil(bytes / 3) × 4

Tips for Better Results

  • Use URL-safe mode for values placed in query strings or paths.
  • Match the decode mode to how the string was encoded.
  • Do not rely on Base64 to hide secrets — it is trivially reversible.
  • Expect roughly 33% size growth when encoding.
  • Strip surrounding whitespace or line breaks before decoding.

Standards and References

Conclusion

The Base64 tool encodes and decodes both standard and URL-safe Base64 with proper UTF-8 handling, exactly per RFC 4648.

Remember it is an encoding for transport, not a security mechanism — use it to move data safely through text channels, not to protect secrets.

Privacy & how it works

This developer utility runs in your browser with JavaScript and Web APIs. Your text, tokens, and secrets are not uploaded to The ToolSphere servers for this tool. Privacy Policy.

FAQ

Is Base64 a form of encryption?expand_more

No. Base64 is a reversible encoding for representing bytes as text. It provides no confidentiality — anyone can decode it. Use real encryption to protect secrets.

What is the difference between standard and URL-safe Base64?expand_more

Standard Base64 uses + and / and = padding. URL-safe Base64 (RFC 4648 §5) uses - and _ instead and usually omits padding, so the value is safe in URLs and filenames.

Why did decoding fail?expand_more

The input is not valid Base64 for the chosen mode. If the string uses - and _ or has no padding, enable the URL-safe option before decoding.

Does it handle emoji and accented characters?expand_more

Yes. Text is encoded to UTF-8 bytes before Base64 and decoded back from UTF-8, so multi-byte characters round-trip correctly.

Why is my encoded string longer than the input?expand_more

Base64 turns every 3 bytes into 4 characters, so output is about one third larger than the original data.

What are the = characters at the end?expand_more

They are padding used when the input length is not a multiple of three. URL-safe output strips them; the decoder restores them automatically.

Can I Base64-encode a file?expand_more

This tool encodes text input. To encode file bytes, load them as text or use a dedicated file-to-Base64 workflow; the same 3-to-4 byte mapping applies.

Is Base64 the same as Base64URL used in JWTs?expand_more

Base64URL is the URL-safe variant. JWT segments use Base64URL without padding, which corresponds to this tool's URL-safe option.

Does encoding change the meaning of my data?expand_more

No. Encoding and decoding are lossless. You recover the exact original bytes as long as you use matching modes.

Is my input uploaded anywhere?expand_more

No. Encoding and decoding run in your browser. Your input is not sent to The ToolSphere servers for this tool.

Is this tool free?expand_more

Yes. No signup and no paywall for core use.

Is my text uploaded?expand_more

No for this tool. Text stays in your browser while you work.

Suggest an improvement

Tell us what would make this tool more useful. We read every suggestion.

Feedback for: Base64 Encode / Decode