Skip to content
Cuisdev

Base64 Encode / Decode

Encode text or files to Base64 and back

  • Runs in your browser
  • No sign-up
  • Free forever
Loading the tool…

How to use the Base64 Encode / Decode

  1. 1

    Choose Encode or Decode. Paste text into the left pane, or drop any file onto it to encode the file's bytes.

  2. 2

    For encoding, pick URL-safe for tokens and query strings, Wrap at 76 for MIME email bodies, or Data URL to get a ready-to-use data:...;base64, string.

  3. 3

    For decoding, paste standard or URL-safe Base64, with or without padding and line breaks, or a whole data: URL. Text appears on the right; binary data gets a Download button and an image preview.

  4. 4

    Press the swap button to turn the output into the new input and reverse the direction.

  5. 5

    Copy the result, or download it as a text file or as the decoded binary.

Features

  • Encodes and decodes UTF-8 text correctly, including accents and emoji
  • Encodes any file (images, PDFs, fonts) by drag and drop, up to 10 MB
  • Standard and URL-safe alphabets, optional 76-character line wrapping, data URL output
  • Decodes input with missing padding, stray whitespace or a data: prefix
  • Detects binary output, sniffs PNG, JPEG, GIF, WebP, PDF, ZIP and gzip, and offers a download with the right extension
  • Shows an inline preview when the decoded data is an image
  • Recognises pasted Base64 and switches to Decode automatically
  • Runs entirely in your browser; nothing is uploaded

Base64 in plain terms

Base64 is a way of writing bytes as text. Every 3 bytes become 4 characters drawn from A to Z, a to z, 0 to 9, plus and slash, with equals signs padding the end. The result survives any system that handles text, which is why email, JSON, HTML data URLs and HTTP headers all lean on it. It is not encryption and it is not compression; it makes data a third larger and hides nothing.

This tool handles the everyday cases: a string that needs to go into a header, a token that needs to be read, an image that needs to become a data URL, and a data URL that needs to become a file again. It understands both the standard and the URL-safe alphabets, forgives missing padding and line breaks, and tells you when the decoded bytes are binary rather than text.

Files and data URLs

Drop a file onto the input pane to encode its bytes. Turn on Data URL and the output is prefixed with the file’s MIME type, ready to paste into an src attribute or a CSS url(). Going the other way, paste a data URL and the tool strips the prefix, decodes the payload, previews it if it is an image and offers it as a download with a sensible extension.

Base64 is one layer of a JWT; the JWT Decoder shows the claims directly. For percent-encoding in URLs rather than Base64, use the URL Encoder, and for escaping text in HTML use the HTML Entity Encoder.

Frequently asked questions

What is Base64 used for?
Base64 represents binary data using 64 printable characters so it can travel through systems built for text: email attachments, data URLs in HTML and CSS, JSON payloads, HTTP basic authentication headers and JWT tokens. It is an encoding, not encryption: anyone can decode it, so never use it to hide secrets.
Why is the encoded text about a third larger than the input?
Base64 packs 3 bytes into 4 characters, so output is 4/3 the size of the input plus padding. The summary under the output shows the exact growth. Compressing before encoding, or sending binary directly where the protocol allows, avoids the overhead.
What is the difference between standard and URL-safe Base64?
Standard Base64 uses + and / and pads with =, all of which have meanings in URLs. The URL-safe variant from RFC 4648 uses - and _ instead and usually drops the padding. JWT tokens and many APIs use the URL-safe form. The decoder accepts both automatically.
Can I decode a Base64 image or PDF?
Yes. Paste the Base64 or the complete data: URL and the tool detects that the bytes are not text, shows a preview for images and offers a download with the right file extension. Nothing is sent anywhere; the file is reconstructed in your browser.
Why does decoding say the result is not UTF-8 text?
The Base64 was valid but the bytes it contained are not a UTF-8 string, which usually means the data is binary, such as an image or a compressed file. Use the Download button to save it. If you expected text, the original may have been encoded with a different character set.
Is my data uploaded anywhere?
No. Encoding and decoding use the browser's own functions and run in your tab. You can disconnect from the internet after the page loads and it keeps working, so tokens, credentials and private files are safe here.

Last updated .