Encode & Decode Base64 Instantly

Encode text and files to Base64 or decode Base64 back to plain text, with URL-safe option, live size stats and instant verification. Runs entirely in your browser.

Status

Enter text or select a file to encode or decode.

Original
Result
Overhead

Output

How to use the Base64 Encoder & Decoder

This tool encodes plain text or files to Base64, and decodes Base64 strings back to readable text, all in your browser. Use it to inspect encoded data, embed images directly in web pages, or verify encoded content. To format decoded JSON content, use the JSON Formatter directly after decoding.

  1. Choose a mode, Encode Text, Decode, or File → Base64 using the tabs at the top of the tool.
  2. Select a variant, Standard Base64 uses the full character set; URL-safe swaps two characters so the result can be used directly in web addresses without issues.
  3. Set the character format (text modes only), UTF-8 supports all languages, emoji and special characters; Latin-1 is for older systems that use a basic single-byte format.
  4. Enter input, type or paste text in the textarea, or drop any file onto the drop zone. Encoding and decoding update live as you type; file encoding requires clicking Encode File.
  5. Read the size ratio bar, the blue segment is the original data, the orange segment is the Base64 overhead. For standard encoding this is always roughly +33%.
  6. Copy or download the output, click Copy to send the result to your clipboard, or Download to save it as a .txt file. Nothing is stored or cached.

The +33% overhead explained

Base64 encodes 3 input bytes into 4 output characters. Each output character represents 6 bits, so 4 characters cover 24 bits, exactly 3 bytes. The ratio 4/3 means the encoded output is always 33% larger than the original binary data, regardless of content. The size ratio bar on this tool visualizes exactly that split: the blue portion is your original data, the orange is the Base64 overhead. When you decode, the process reverses, 4 characters collapse back to 3 bytes and the overhead disappears.

Standard vs URL-safe Base64

There are two variants of Base64. Standard uses + and / in its character set, which cause problems inside web addresses. URL-safe replaces those two characters with - and _, making the result safe to use directly in links, file names and web requests. Always use the same variant on both sides, mixing them will produce garbled output even though both look like normal text.

Frequently asked questions

What is Base64 encoding and when should I use it?

Base64 is a way to convert any data, images, files, binary content, into plain text characters that can be safely sent through systems that only handle text. It is used to embed images directly in web pages, to attach files in emails, and to pass file content through web services. The trade-off is a predictable 33% size increase: every 3 bytes of input become exactly 4 Base64 characters of output.

How does the URL-safe Base64 variant differ from standard Base64?

Standard Base64 uses + and / in its character set. Both have special meaning inside web addresses: + is read as a space and / separates sections of a link, so pasting standard Base64 into a URL corrupts the value. The URL-safe variant replaces + with – and / with _, which are harmless in links, file names and cookies. This tool also removes the trailing = characters because many systems that accept URL-safe Base64 don't expect them.

Does this tool send my data to a server?

No. All encoding and decoding runs entirely in your browser. File encoding runs in the background so the page stays usable while large files are processed. PureTools has no server, your text and file contents never leave your device. Your input is kept only for the current tab session and erased automatically when you close the tab. Your data is never used to train AI models or improve machine learning systems.

Why does Base64 output always end with = or == signs?

Base64 works by encoding groups of 3 characters at a time into 4 output characters. When the content doesn't divide perfectly into groups of 3, the encoder pads the end with one or two = signs to complete the last group. This is normal and expected. Some systems don't need the = signs because they can figure out the original length without them, the URL-safe toggle on this tool removes them for those cases.

Can I encode any file type to Base64?

Yes. The File tab accepts any file type, images, PDFs, fonts, archives, text files. The file is processed in the background and the result appears in the output area. The most common use case is embedding a file directly in a web page, prefix the encoded output with data:[file-type];base64, to embed it in an HTML image tag or a CSS background without needing a separate file request. To generate a fingerprint of your file instead, use the Hash Generator.

What size limit does the file encoder have?

The file encoder accepts files up to 10 MB. Since Base64 adds 33% overhead, a 10 MB file produces a 13.3 MB result in memory. For typical use cases, embedding small icons, fonts or thumbnail images, files are well under 500 KB. For very large files, it's better to use a command-line tool to avoid storing huge amounts of text in the browser at once.

How do I embed a Base64-encoded image in HTML or CSS?

Encode your image on the File tab, then copy the output. In HTML, use: <img src="data:image/png;base64,ENCODED_STRING">, replace image/png with the correct file type (image/jpeg, image/svg+xml, image/webp). In CSS, use: background-image: url('data:image/svg+xml;base64,ENCODED_STRING'). This technique lets you embed an image directly in the page without a separate file, but increases the page size by 33%, so it is best reserved for small assets under 4–5 KB. Larger images should be served as separate files for better performance.

What is the difference between UTF-8 and Latin-1 for Base64 encoding?

UTF-8 is the modern standard that supports all languages, emoji and special characters. Latin-1 is an older format that only covers basic Western European characters, anything beyond that (Chinese, Arabic, emoji, etc.) will produce an error. Choose UTF-8 for any modern text. Latin-1 is only needed when working with older systems that specifically expect that format.

How can I verify that my Base64 string is valid?

Switch to the Decode tab and paste your Base64 string. The tool will attempt to decode it immediately and show the result or an error message. Any character outside the Base64 alphabet, including spaces, line breaks or special symbols, will make the string invalid. If you copied the string from a document or email, check for accidental line breaks or spaces added during copy-paste, as these are the most common cause of decoding failures. The JSON Formatter can help you read any decoded JSON content.