JustGenerator
Encoding 100% Client-Side Privacy

Base64 Encoder & Decoder

Encode UTF-8 text or local files into Base64, or decode Base64 and Base64URL strings back into readable text right inside your browser.

0 chars
0 chars

Encode a Local File to Base64

Great for small SVG/PNG data URIs or API file upload testing. Runs locally in your browser.

Why native btoa() breaks on Unicode (and how this tool avoids it)

If you open a browser console and run btoa("café") or btoa("🚀"), JavaScript throws an InvalidCharacterError because btoa() only accepts single-byte Latin-1 characters. Plenty of quick Base64 web pages wrap btoa() directly and break the moment you paste a UTF-8 JSON payload or a non-English name.

This converter encodes text through new TextEncoder().encode(value) before converting bytes to Base64, and restores decoded bytes through new TextDecoder("utf-8"). That means emojis, accented characters, and multi-byte scripts round-trip cleanly. Hit Swap Input & Output after encoding to verify that your exact original text comes back untouched.

Standard Base64 versus Base64URL in JWTs and OAuth

Standard Base64 (RFC 4648 Section 4) uses +, /, and trailing = padding. Put those characters inside a query string and HTTP servers turn + into a space or treat / as a path separator. Base64URL (RFC 4648 Section 5) swaps + for -, swaps / for _, and drops the trailing = padding.

Check the URL-Safe (Base64URL) box when encoding JWT headers, OAuth state parameters, or URL tokens. In Decode mode, this tool accepts both standard Base64 and unpadded Base64URL automatically, so you can paste the middle segment of a JWT directly into the input box and read the JSON claims without manually adding = signs.

Everyday debugging tasks for local Base64 conversion

  • Decoding Kubernetes Secret values from YAML manifests without sending production environment variables to a remote server.
  • Building HTTP Basic Auth headers (Authorization: Basic ...) from username:password without the trailing newline that echo "user:pass" | base64 accidentally sneaks in.
  • Converting a small SVG icon or 2 KB PNG into a Base64 string via the Choose File button at the bottom of the workspace. Keep in mind Base64 inflates binary size by about 33%, so avoid inlining large images.

Remember that Base64 is encoding, not encryption. Anyone who sees a Base64 string can decode it immediately. If you need integrity hashes for decoded payloads, use our SHA-256 Hash Generator; if you need unpredictable secret keys, use our Random Token Generator.

Common questions

Is Base64 a form of encryption?

No. Base64 is a public encoding format, not encryption. There is no secret key, and anyone who sees a Base64 string can decode it back to the original text in less than a second. Never rely on Base64 to protect passwords, API secrets, or personal data.

Why is Base64 encoding used in web development and APIs?

Base64 converts raw binary bytes or complex text into 64 safe ASCII characters (A-Z, a-z, 0-9, +, and /). This prevents corruption when binary files, images, or JSON payloads pass through text-only systems like HTTP Basic Auth headers, MIME emails, XML, and HTML data URIs.

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

The equals signs at the end of a Base64 string are padding characters. Base64 encodes input in 3-byte (24-bit) blocks that become 4 text characters. When the final block has only 1 or 2 bytes, one or two = characters pad the output to a multiple of 4.

What is the difference between standard Base64 and Base64URL?

Standard Base64 uses + and /, which have reserved meanings inside URLs and query parameters. Base64URL replaces + with - and / with _, and usually omits the trailing = padding. JSON Web Tokens (JWTs) and OAuth state parameters use Base64URL.

Does Base64 encoding increase file size?

Yes. Because Base64 maps every 3 bytes of binary input into 4 ASCII characters, the encoded text is roughly 33% larger than the original data. That overhead is fine for small icons, tokens, and headers, but large files should normally be served as binary downloads.

How do I encode or decode Base64 with UTF-8 characters in JavaScript?

Native btoa() and atob() only accept Latin-1 characters and throw an error on emojis or non-ASCII text. Converting strings through TextEncoder and TextDecoder before calling btoa() or atob() handles full UTF-8 text cleanly, which is how this tool works.