Free & Private Online Browser Utility

Base64 Encode & Decode Text, Image & File

Base64 encodes binary data and UTF-8 text into a 64-character ASCII alphabet so it can be embedded in JSON, HTML, CSS, and URLs without corruption. This tool runs the encoding and decoding entirely in your browser: the Web Crypto API is not involved — the engine uses the standard JavaScript btoa and atob functions behind a UTF-8 safety layer built from encodeURIComponent and decodeURIComponent. Non-ASCII characters, including multi-byte Unicode and emoji, are percent-encoded to single-byte sequences before btoa sees them, so the result is correct RFC 4648 Base64 for any Unicode input. URL-safe mode is also implemented: the toBase64Url function replaces the standard + with a hyphen and / with an underscore, then strips the trailing = padding characters, producing a Base64URL string suitable for JWT headers and query parameters. File encoding uses the FileReader.readAsDataURL API which returns a full data URI including the MIME type prefix.

How to use

  1. Step 1: Choose Text or File Mode

    Use the Text & String Workspace tab to encode or decode a string. Use the File Workspace tab to convert an image, PDF, font, or any binary file into a data URI.

  2. Step 2: Paste or Type Your Input

    In text mode, type or paste your string into the left panel. In file mode, drag a file onto the drop zone or click Browse to select it from your device.

  3. Step 3: Copy or Download the Result

    Copy the encoded or decoded output to the clipboard, generate an HTML img or CSS background-image snippet from a file data URI, or download the result as a .txt file.

Options explained

Standard vs URL-Safe Mode

Standard Base64 uses + and / with = padding. URL-Safe Base64 replaces + with - and / with _ and removes padding so the string can appear in URLs and JWT tokens without percent-encoding.

When to use: Use URL-Safe when building JWTs, embedding tokens in query strings, or storing Base64 in cookie values.

Line Wrapping (PEM / MIME)

Applies a line break every 64 characters (PEM/OpenSSL standard) or every 76 characters (MIME/email standard) to the encoded output.

When to use: Use 64-char wrapping when pasting into SSH authorized_keys or OpenSSL certificate files; use 76-char for email attachments.

File Mode

Reads the selected binary file with FileReader.readAsDataURL, extracting the raw Base64 from the data URI and displaying the full Data URI for embedding.

When to use: Use when you need to inline an image as a CSS background-image or an HTML img src without an external HTTP request.

Worked example

Input: Hello, ToolVerve!

Output: SGVsbG8sIFRvb2xWZXJ2ZSE=

The string Hello, ToolVerve! encodes to SGVsbG8sIFRvb2xWZXJ2ZSE= in standard Base64. Decoding that string returns the original text.

Tips & limits

  • Base64 increases payload size by roughly 33 percent compared to raw bytes. For images already served over HTTP, prefer a standard URL over a data URI.
  • window.btoa throws InvalidCharacterError on code points above 255. This tool pre-encodes the string with encodeURIComponent before calling btoa to avoid that error.
  • URL-Safe Base64 is not the same as percent-encoding. They serve different purposes and cannot be substituted for each other.

Common problems

Decoding produces garbled characters or question marks

The input may be standard Base64 but the decode mode is set to URL-Safe or vice versa. Check that the mode matches the encoding that produced the string.

File data URI is very long and slows the page

Large binary files produce very long data URIs. For files above 100 KB, a standard URL served over HTTP is more efficient than an inline data URI.

Frequently Asked Questions (FAQ)

How does this tool handle non-ASCII text and emoji?

The engine converts multi-byte Unicode strings using btoa(unescape(encodeURIComponent(str))), which escapes UTF-8 percent-encoded bytes so btoa processes each byte accurately without throwing an invalid character exception, preserving characters like é (w6k=) and emoji (Héllo 😀 -> SMOpbGxvIPCfmIA=).

What is URL-Safe Base64 and when should I use it?

URL-Safe Base64 (RFC 4648 §5) replaces + with - and / with _ and removes = padding. Use it for JWT tokens, query string parameters, and cookie values where + would be misread as a space and / would be treated as a path separator.

Does Base64 encrypt or compress my data?

No. Base64 is an encoding scheme, not encryption. Anyone with the encoded string can decode it immediately. It also increases size by about 33 percent so it provides no compression benefit.

Is my data sent to a server?

No. All encoding and decoding runs in browser RAM using btoa, atob, and FileReader. No data leaves your device.

Files never leave your device; calculations and transformations happen locally.

Last reviewed: 2026-10-18 · Build: deb3bc0