HassleFreeTools

Base64 Encoder and Decoder

Encode text or files to Base64 and decode Base64 back to text or a downloadable file. Supports UTF-8, URL-safe Base64 and data URIs.

Text to encode

0 characters

Uses - and _ instead of + and / (RFC 4648, section 5), for URLs, file names and tokens.

Leaves out the = signs at the end, as JWTs and many URL formats do.

Adds a line break every 76 characters, the MIME email format (RFC 2045).

Base64

Runs entirely in your browser. Your files and text are not uploaded.

How to use Base64 Encoder and Decoder

  1. Step 1: Choose what to convert

    Pick Text or File at the top, then Encode or Decode.

  2. Step 2: Add your input

    Type or paste text, paste Base64 or a data URI, or drop a file of up to 10 MB.

  3. Step 3: Copy or download

    Copy the result, save it as a .txt file, or download the decoded file with its detected extension.

How Base64 encoding works

Base64 writes any data as plain text using 64 characters that survive email, JSON and URLs: A–Z, a–z, 0–9, + and /. The encoder takes the data three bytes (24 bits) at a time and splits them into four groups of 6 bits. Each 6-bit value, from 0 to 63, becomes one character. When the data does not divide evenly into groups of three bytes, the last group is completed with one or two = signs, called padding. That is why Base64 is always about a third longer than the original: every 3 bytes become 4 characters.

Text is first turned into bytes with UTF-8, the encoding used across the web. Hindi, emoji and accented letters are therefore encoded correctly and decode back to exactly the same text. Tools built on the browser's btoa() function fail on such characters; this one does not use it.

The options

  • URL-safe alphabet replaces + with - and / with _, as defined in RFC 4648, section 5. Use it when the result goes into a URL, a file name or a token such as a JWT, where + and / have other meanings.
  • Remove = padding leaves out the trailing = signs. The decoder can work them out from the length, so formats such as JWT drop them.
  • Wrap lines at 76 characters splits the output into lines of 76 characters, the limit for MIME email attachments in RFC 2045. Lines are separated with a line feed (LF).
  • Data URI (File mode) puts the media type in front of the Base64, for example data:image/png;base64,iVBORw0…. It can be pasted straight into an HTML src attribute or a CSS url().

Decoding

The decoder accepts both alphabets, with or without padding, and ignores spaces and line breaks, so Base64 copied from emails, logs or source code works as it is. A data URI prefix and the BEGIN and END lines of a PEM block (the format used for certificates and keys) are skipped automatically. When a character cannot be part of Base64, the tool names it, gives its position and can select it in the input box, which makes stray quotes, percent signs or invisible characters easy to find.

In File mode, the type of the decoded file is worked out from its content (the signature in its first bytes), not just from what a data URI claims. PNG, JPG, GIF, WebP, SVG, PDF, ZIP, Word, Excel and PowerPoint files, MP3 and MP4 media, fonts and plain text are recognised and get a matching file extension. Images and text are previewed before you download them.

Base64 is not encryption

Anyone can decode Base64. It only changes how data is written, not who can read it, so it does not protect passwords or personal data. Everything on this page runs in your browser; your text and files are not uploaded.

Limitations

  • Files and decoded results are limited to 10 MB. The Base64 text of a 10 MB file is about 14 million characters.
  • Text is always encoded as UTF-8. Other character sets, such as Windows-1252 or UTF-16, are not offered; use File mode to work with exact bytes.
  • Line breaks typed in the text box are encoded as LF (Unix style). To keep Windows CRLF line breaks, encode the file itself in File mode.
  • Very long results are shortened in the output box to keep the page responsive. Copy and Download always use the full result.
  • Unusual binary formats may not be recognised and are saved as .bin; rename the file if you know its type.
  • Data URIs without “;base64” (percent-encoded text) are not decoded.
  • When a PEM file holds several blocks, such as a certificate chain, only the first block is decoded.

Frequently asked questions

Is Base64 a form of encryption?

No. Base64 is an encoding, not encryption. Anyone can turn it back into the original data without a key, so never rely on it to hide passwords, tokens or personal information.

Why is the Base64 longer than my original text or file?

Every 3 bytes of data become 4 characters, so Base64 is about 33% larger, plus up to two = signs of padding. A 1 MB image becomes about 1.33 MB of text, and wrapping lines at 76 characters adds a line break for each line.

What is the difference between Base64 and Base64URL?

Base64URL (RFC 4648, section 5) uses - and _ instead of + and /, because + and / have special meanings in URLs and file names, and it usually leaves out the = padding. Switch on “URL-safe alphabet” and “Remove = padding” to create it. The decoder accepts both forms automatically.

Why do I get an “Invalid character” error?

Base64 can only contain letters, digits, + and / (or - and _), with = at the end. Common causes are quotes copied along with the string, URL encoding such as %2B or %3D (decode the URL first), an HTML snippet around a data URI, or two strings pasted together. The message shows the character and its position, and “Show it in the input” selects it.

How do I turn a Base64 string back into an image or PDF?

Choose File and Decode, then paste the Base64 or the whole data URI. The tool detects the file type from the data, shows a preview for images and gives the file a matching extension, such as .png or .pdf. Check the name and press “Download file”.

Are my text and files uploaded anywhere?

No. Encoding and decoding happen in your browser with JavaScript. Nothing you paste or choose is sent to our server, and it is gone when you close the page.

Encode text for safe use in URLs or decode percent-encoded strings, with component, full URL and form (+ for space) modes.

Format, minify and validate JSON in your browser. Errors are shown with the exact line and column, and numbers are kept exactly as written.

Create QR codes for websites, text, email, phone calls and SMS. Choose the colours and error correction, then download a PNG or SVG.