Skip to main content

Base64 encoder/decoder

Encode and decode Base64 strings. Supports URL-safe encoding, data URIs and an automatic image preview.
Conversion
Choose a mode and enter your data
Text input

0 characters

Base64 output

0 characters

URL-safe Base64
StandardURL-safeReason
+-+ is read as a space in URLs
/_/ separates path segments in URLs
=(removed)= has a special meaning in query strings

Used for: JWT tokens, file names, URL parameters, API keys

About Base64

Data URIs

Embed small images directly in HTML or CSS:data:image/png;base64,...

JWT tokens

JSON Web Tokens consist of three Base64-encoded parts separated by dots.

API auth

HTTP Basic authentication uses Base64 to transmit credentials.

How to encode text and files with Base64

  1. Choose the mode 'Encode' at the top.
  2. Type or paste your text, or upload a file with 'File'.
  3. The result appears right away in the output field. Turn on 'URL-safe' or 'Data URI' if you need them.
  4. Copy the output with 'Copy'.

The tool encodes text as UTF-8. Accented letters and other non-ASCII characters come back exactly as you typed them when you decode.

Decoding Base64

Switch to 'Decode' and paste the string. You don't need to clean it up first. The decoder removes spaces and line breaks and strips a leading data:...;base64, prefix on its own. It also accepts URL-safe strings with - and _ and a missing = at the end, without a switch.

It reads the result as UTF-8 text. If the string holds a binary file such as a PDF, the tool says the result is not valid UTF-8 text instead of printing garbage. If it is an image, the tool shows a preview instead. The swap button moves the output into the input of the other mode.

Embedding images as data URIs

If you upload an image with 'File', you get its Base64 value. With the option 'Data URI', the tool puts the matching prefix in front, for example data:image/png;base64,. For files it uses the type of the file. For typed text you pick the media type from the list, for example image/svg+xml or text/css.

The image preview recognizes PNG, JPEG, GIF, WebP, SVG and ICO from the first characters of the string and offers a download. This also works if you paste only the Base64 value without a prefix.

When the decoder shows an error

The message 'That isn't a valid Base64 string' usually means the string was cut off or contains characters outside the Base64 alphabet.

  • Check that you copied the whole string, including the last characters.
  • For a JWT, decode each of the three parts on its own. The dots are not part of Base64.
  • Remove quotation marks if you copied the value from a JSON file.

Frequently asked questions

Everything about Base64 encoding
What is Base64 encoding?
Base64 is an encoding that turns binary data into ASCII characters. It is commonly used to embed images in HTML or CSS, to carry data in URLs and to encode email attachments.
What is URL-safe Base64?
URL-safe Base64 replaces the characters + and / with - and _, because both have special meanings in URLs. It also drops the = padding. This matters for query parameters, file names and JWT tokens.
What is Base64 used for?
Base64 is used for data URIs in HTML and CSS, email attachments (MIME), JSON Web Tokens (JWT), API authentication and for storing binary data in text formats.
Is Base64 encryption?
No. Base64 is an encoding, not encryption. Anyone can decode the data without a key. If you need to protect data, use real encryption.
Why does Base64 make data bigger?
Base64 uses 4 ASCII characters to represent 3 bytes, so the data grows by about 33%. That is the price for compatibility with text formats.
Can I convert files to Base64?
Yes. Upload a file and the tool shows its Base64 value. This is useful for small images you want to embed directly in HTML or CSS.
Is my data stored?
No. The whole conversion runs locally in your browser, including uploaded files. Nothing is sent to our servers.
Can I decode Base64 to a PDF or another file?
Only to a limited extent. The tool shows the result as UTF-8 text. It recognizes images (PNG, JPEG, GIF, WebP, SVG, ICO) and offers them as a download. For other binary data such as a PDF, it reports that the result is not valid text and offers no download.

Related tools

All tools

Changelog

Latest updates and improvements to the Base64 encoder
v1.4.0

November 20, 2026

Options apply to uploaded files

  • • Fixed: after a file upload, URL-safe, Data URI and the media type now apply to the file. Before, the data URL text in the input field was encoded a second time.
  • • Fixed: when you decode a Base64 image, only the image preview appears, no longer the UTF-8 error message as well.
  • • The FAQ explains that files are also processed only in your browser and that binary data such as a PDF cannot be downloaded as a file.
v1.3.0

November 18, 2026

Message for invalid UTF-8

  • • When decoding binary data, the tool now reports "The result is not valid UTF-8 text" instead of silently printing replacement characters.
v1.2.0

November 17, 2026

Guide and related tools

  • • Added a guide with instructions and use cases directly below the tool.
  • • Added related tools at the end of the page.
Show older versions
v1.1.0

December 20, 2025

URL-safe Base64 and image preview

  • • Added a URL-safe Base64 option (+ becomes -, / becomes _).
  • • Added an automatic image preview for Base64-encoded images.
  • • Added a data URI generator with a media type selection.
  • • Added an image download button.
v1.0.0

December 17, 2025

Launch

  • • Encode text to Base64.
  • • Decode Base64 to text.
  • • Upload a file to get its Base64 value.
  • • Copy with one click.
  • • Real-time conversion.
  • • Runs entirely in the browser.