OnSumoTools

Base64 Encoder / Decoder

This tool converts text to Base64 and Base64 back to text entirely in your browser. Paste a string and get its Base64 representation, or paste a Base64 string and get back the original content. No data leaves your device. The tool supports standard Base64 (RFC 4648), URL-safe Base64, and handles UTF-8 multi-byte characters correctly. It is free, requires no login, and works offline once the page loads.

Mode

Output

Standard

Input 11 chars → Output 16 chars

Base64 is encoding, not encryption. Anyone with the string can decode it. Do not use Base64 to hide secrets.

How does the Base64 Encoder / Decoder work step by step?

The Base64 encoder converts binary or text data to and from Base64 encoding, where every 3 bytes of input are represented as 4 printable ASCII characters drawn from the 64-character alphabet (A-Z, a-z, 0-9, +, /), with = padding to align output to a multiple of 4 characters. The URL-safe variant replaces + with - and / with _ to produce Base64 strings safe for use in URLs and query parameters without percent-encoding. The tool handles both standard Base64 and Base64url, auto-detecting which encoding is present during decoding. For text inputs, encoding runs on the UTF-8 byte representation, not on raw code-point values, so multi-byte characters (emoji, Chinese characters, Arabic text) encode correctly. All encoding and decoding runs entirely in the browser; no data is sent to any server, which matters when the input contains API keys, credentials, or other sensitive values. Key assumption: Base64 is an encoding scheme, not encryption. Base64-encoded data is fully reversible without any key. Edge case: Base64 encoding increases output size by approximately 33% (4 output bytes per 3 input bytes). For inline image data URIs embedded in CSS or HTML, this size increase can significantly affect page weight. A 100KB image becomes a ~133KB Base64 string.

What does a typical Base64 Encoder / Decoder result look like?

"Hello World" encodes to SGVsbG8gV29ybGQ=. URL-safe swaps + and / for - and _ and drops padding. MIME wraps the same payload at 76 characters per line.

Related tools

Frequently asked questions

  • What is the difference between Base64 and Base64url?

    Standard Base64 uses + and / as the 63rd and 64th characters, with = for padding. Base64url replaces + with - and / with _, and typically omits padding. Base64url is used in JWTs, URL parameters, and filenames because +, /, and = have special meanings in URLs and file systems. This tool supports both variants. Select \\\\\\\"URL-safe\\\\\\\" mode to use the Base64url alphabet.

  • Is my data sent to a server?

    No. All encoding and decoding runs in your browser's JavaScript engine. No network requests are made with your data. You can confirm this by watching the Network tab in your browser's DevTools while using the tool. This is important when encoding API keys, passwords, tokens, or any credentials.

  • Why does Base64 make the output larger?

    Base64 represents 3 bytes of input as 4 ASCII characters. That is a 33% size increase. This overhead exists because Base64 uses only 64 characters (6 bits per character), while binary data uses 256 possible values per byte (8 bits). The tradeoff is that Base64 output is safe to transmit through systems that only handle text, such as email (MIME), JSON, XML, and HTTP headers.

  • Can I encode binary files like images or PDFs?

    Yes, if you provide the binary content. In the browser version, you can drag and drop a file onto the input area and the tool will read it as binary and produce the Base64 output. For large files (over 1 MB), the encoding may take a moment because the browser needs to read the entire file into memory.

  • How do I know if a string is valid Base64?

    Valid standard Base64 contains only characters A-Z, a-z, 0-9, +, /, and optionally ends with one or two = padding characters. The length of a valid Base64 string (excluding whitespace) is always a multiple of 4. If the decoder reports an error, the input contains characters outside this set or has an incorrect length.

  • What happens with UTF-8 characters like emoji?

    The browser's btoa() function only handles ASCII (code points 0-255). This tool first encodes your text to UTF-8 bytes using TextEncoder, then Base64-encodes those bytes. The decoder reverses the process: Base64-decode to bytes, then TextDecoder to UTF-8 text. This means emoji and characters from any language encode and decode correctly.

What Base64 is for

Base64 turns binary data into plain text made of letters, numbers and a couple of symbols. That lets you move images, files and tokens through systems built only for text, like email, JSON and URLs.

It isn't encryption. Anyone can decode it. Never treat Base64 as a way to hide a password.

Standard, URL-safe and MIME

Standard Base64 uses plus and slash characters, which cause trouble inside URLs. The URL-safe version, often called Base64url, swaps them for a dash and an underline character and usually drops the padding. JWTs use it.

MIME Base64 breaks the output into lines of fixed length, which email systems expect. Pick the variant the receiving system asks for. Using the wrong one is the most common reason a decode fails.

Text, files and images

Type or paste text to encode it, or paste a Base64 string to decode it. You can also upload a file, such as a PDF or an image, and get its Base64 back. For images, the tool shows a preview so you can confirm the decoded result is what you expected.

Text is handled as UTF-8, so emoji and accented characters survive the round trip. If you ever see broken symbols after decoding, the source was likely using a different character encoding.

Why the output is bigger

Base64 grows your data by about a third. Three bytes become four characters. That's the price of making binary safe for text. For a tiny icon inside a stylesheet it's fine. For a large photo, a normal file link is the better choice.

Checking if a string is valid

A valid Base64 string only uses the allowed characters, and its length works out to a multiple of four once padding is added. Equals signs may appear at the end. If decoding fails, look for stray spaces, line breaks that shouldn't be there, or a URL-safe string being read as standard.

Your data stays put

Encoding and decoding happen in your browser. Nothing you paste or upload is sent to a server, so it's reasonable to check a token or a small file here. Still, avoid pasting live secrets into any tool when you can avoid it.