Dexaloop Tools

Base64 encode and decode

Encode text or a file to Base64, or decode Base64 back to text, an image or a file, in your browser. Nothing you type leaves your browser.

Direction
Encode from

Text is encoded as UTF-8, so emoji and every script work.

Your entries are not saved or sent
Encoded
0 characters
Type some text or choose a file to encode it.

Base64 is an encoding, not encryption: anyone can decode it. Encoding and decoding follow RFC 4648 and run in this page; files are never uploaded.

How to use the Base64 encoder and decoder

  1. Pick Encode or Decode.
  2. To encode, type or paste text, or switch to File and choose or drop any file. Text is turned into UTF-8 bytes first, so emoji, accents and Arabic come back exactly as typed. The output can be plain Base64 or a data: URL ready for HTML or CSS.
  3. To decode, paste Base64, Base64url or a whole data: URL. Spaces, line breaks and missing = padding are fine. You get the text, a picture if the bytes are an image, or a download for anything else.
  4. Copy or download the result. The download is named for what the bytes are, such as decoded.png or decoded.pdf.

Options for encoding: URL-safe alphabet gives Base64url, Leave out = padding drops the trailing = signs, and Line breaks wraps the output every 76 characters (MIME) or 64 (PEM). Everything runs in this page: your entries are not saved or sent.

Base64 encode: how it works, with examples

Base64 is defined in RFC 4648. The encoder reads the input 3 bytes (24 bits) at a time and writes 4 characters, each carrying 6 bits: in the RFC's words, "A 65-character subset of US-ASCII is used, enabling 6 bits to be represented per printable character." The 65th character is =: "Padding at the end of the data is performed using the '=' character." One leftover byte gives 2 characters and ==; two leftover bytes give 3 characters and =.

InputUTF-8 bytesBase64
f1Zg==
fo2Zm8=
foo3Zm9v
foobar6Zm9vYmFy
Hello5SGVsbG8=
é2w6k=
👋48J+Riw==
مرحبا102YXYsdit2KjYpw==

The f, fo, foo and foobar rows are test vectors printed in RFC 4648 section 10. The size rule follows: output length is 4 times the number of bytes divided by 3, rounded up to a whole group of 4, so Base64 is about 33% bigger than the data. A 3 MB photo becomes 4 MB of text.

Why UTF-8 matters: the browser's own btoa() only accepts characters up to code 255 and fails on 👋. This tool converts text to UTF-8 bytes first, which is what other programs expect when they decode it.

Base64 decode online: text, images and files

Decoding reverses the steps: every 4 characters become 3 bytes. Then the tool looks at the bytes to decide how to show them.

  • Text: if the bytes are valid UTF-8, you see the text. If they are not (for example byte 0xFF, which can never appear in UTF-8), the page says so, shows a hex view and offers the bytes as a file. Base64 does not record whether it holds text, so this check is the only way to tell.
  • Base64 to image: PNG, JPEG, GIF, WebP and SVG are recognized from their first bytes and previewed. SVG is shown only as a picture, never inserted into the page, so any script inside it cannot run.
  • Base64 decode to PDF or another file: PDF, ZIP, audio, video and unknown data get a download button with a matching extension.

You can often tell the type from the first characters of the Base64 itself:

Base64 starts withBytes start withFile type
iVBORw0KGgo89 50 4E 47 0D 0A 1A 0APNG image
/9j/FF D8 FFJPEG image
R0lGODGIF8GIF image
UklGRRIFFWebP (or WAV)
JVBERi0%PDF-PDF document
UEsDBPKZIP, also .docx and .xlsx
PHN2Zy or PD94bWwg<svg and a space, or <?xml and a spaceSVG image (the second can be any XML file)

RFC 4648 says decoders "MUST reject the encoded data if it contains characters outside the base alphabet" unless told otherwise. This page skips white space and line breaks (common in email and PEM files) but reports any other stray character with its position, rather than guessing.

Base64 data: URLs for images

A data: URL puts a whole file inside a link. RFC 2397 gives the form data:[<mediatype>][;base64],<data>, and "The appearance of ";base64" means that the data is encoded as base64." So a tiny PNG might be written data:image/png;base64,iVBORw0KGgo... and used directly as an image source in HTML or CSS.

To make one, choose Output: data: URL and encode a file; the media type comes from the file. To read one, paste it whole into Decode: the prefix is read, its type is shown, and only the part after the comma is decoded. Keep data: URLs for small images and icons, since the 33% size growth adds up.

Base64url: the URL and filename safe alphabet

Standard Base64 uses + and /, which mean something in URLs and file paths. RFC 4648 section 5, "Base 64 Encoding with URL and Filename Safe Alphabet", swaps character 62 to - and character 63 to _; everything else is the same. Section 3.2 also notes that "In some circumstances, the use of padding ("=") in base-encoded data is not required or used", and Base64url is usually written without it. JSON Web Tokens use exactly this form, which is why the JWT decoder can read their parts.

BytesStandard Base64Base64url, no padding
Hi? (48 69 3F)SGk/SGk_
👋 (F0 9F 91 8B)8J+Riw==8J-Riw
FB FF BF+/+/-_-_

The decoder here accepts either alphabet, with or without padding. It refuses a text that mixes + or / with - or _, because that usually means two pieces were joined by mistake. Base64 is not the same as URL encoding: to put a value in a query string, use the URL encoder.

Line breaks: 76 for MIME, 64 for PEM

Email and certificate files break Base64 into lines. RFC 4648 section 3.1 notes that "MIME enforces a limit on line length of base 64-encoded data to 76 characters" and "PEM uses a line length of 64 characters." Choose the matching option when you encode for those uses; leave it at one line for JSON, URLs and code. The line breaks are not part of the data, and the decoder ignores them.

Base64 decode command: Linux, macOS, PowerShell and Python

WhereDecodeNotes from the official docs
Linux (GNU coreutils)base64 -d in.txt > out.pdf-d is "decode data". "When decoding, the input may contain newlines in addition to the bytes of the formal base64 alphabet." Encode with base64 -w 0 for one line (the default wrap is 76).
macOS Terminalbase64 -d -i in.txt -o out.pdfThe macOS man page says base64 "acts as a base64 decoder when passed the --decode (or -d) flag"; its synopsis also lists -D.
PowerShell[IO.File]::WriteAllBytes("$PWD\out.pdf", [Convert]::FromBase64String((Get-Content in.txt -Raw)))White space is ignored, but it throws FormatException if the length, "ignoring white-space characters, is not zero or a multiple of 4". It only knows + and /, so convert Base64url and add padding first.
Pythonbase64.b64decode('SGVsbG8=') gives b'Hello'"A binascii.Error exception is raised if s is incorrectly padded." For Base64url use base64.urlsafe_b64decode.

For text in PowerShell, wrap the bytes: [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('SGVsbG8=')) returns Hello.

Large files and privacy

Files up to 25 MB can be encoded. The result panel shows how long encoding or decoding took on your device. Showing many megabytes of text is slower than computing it, so the output box shows the first 1,000,000 characters and Copy and Download give all of it. Decoded bytes are never uploaded, and the image preview is made from a local blob: link.

Remember that Base64 hides nothing: anyone can decode it. Do not use it to protect passwords or keys, and think twice before pasting live secrets into any website. If the decoded text is JSON, the JSON formatter lays it out and checks it.

Questions and answers

Is Base64 encryption?

No. Base64 is an encoding that anyone can reverse without a key. It only makes binary data safe to carry as text, such as in email, JSON or a URL.

Why does my Base64 end with = or ==?

The = signs are padding. Base64 works in groups of 3 bytes; when the data ends with 1 leftover byte you get ==, with 2 leftover bytes you get =. Some formats, such as Base64url in JWTs, leave the padding out.

Why does decoding give strange characters instead of text?

The data is probably not text: it may be an image, a PDF or compressed data. This page checks the bytes and offers a preview or a download instead. If it was text in an old encoding such as Windows-1252, it will not be valid UTF-8.

How do I convert Base64 to an image?

Paste the Base64, or the whole data:image/...;base64, URL, into Decode. PNG, JPEG, GIF, WebP and SVG are previewed, and Download saves the image with the right extension.

How much bigger is Base64 than the original?

About a third bigger: every 3 bytes become 4 characters, so 30,000 bytes become 40,000 characters. Line breaks add a little more.

What is the difference between Base64 and Base64url?

Only two characters: Base64url uses - and _ where Base64 uses + and /, so the result can sit in a URL or a file name. Padding is usually left out in Base64url.

Sources

Checked on 13 October 2026. If a rule has changed, please tell us.

More developer tools

All developer tools