Skip to content

Base64 Encoder/Decoder

Paste a Base64 string to download the PDF, image or file it holds, or to read it as text. You can also encode text to Base64 as you type, or turn an image or any file up to 5 MB into Base64 or a data URL. Text is read as UTF-8, so accents and emoji survive the round trip, and URL-safe Base64 decodes too.

Text to Base64

Before

Hello, Toolsy Hub!

Plain text

After

SGVsbG8sIFRvb2xzeSBIdWIh

Base64, ready to copy

Text to encode

Try sample texts:

Operation

Base64 encoded

Base64 encoded text will appear here...

Usage tips

  • Encode: Convert text to Base64 format for safe transmission
  • Decode: Convert Base64 strings back to readable text, or to a file such as a PDF or image. URL-safe Base64 and missing padding work too
  • Base64 is commonly used in web development and data storage
  • Use the swap button to quickly switch between input and output
  • Text is encoded as UTF-8, so accents and emoji round trip correctly

How to encode and decode Base64

  1. Pick Encode to turn text into Base64, or Decode to turn Base64 back into text. To encode an image or another file, pick Encode, then File, and drop a file of up to 5 MB.
  2. Type or paste into the box. The result shows on the right as you type. Spaces and line breaks inside Base64 are ignored when decoding.
  3. If the Base64 holds a file, such as a PDF or an image, the tool names its type and size and gives a download button. If decoding fails, the message says why: a character that does not belong, or the wrong length or padding.
  4. Copy or download the result, or click Swap input and output to run it back the other way. For text that goes inside a link, use URL Encoder/Decoder instead.

Frequently asked questions

What is Base64 encoding?

Base64 writes any data with just 64 safe characters: A-Z, a-z, 0-9, + and /, with = as padding at the end. Every 3 bytes become 4 characters. It lets binary data or special characters travel where only plain text fits, such as email attachments, data URLs and JSON fields.

Sources: IETF, RFC 4648: Base16, Base32 and Base64 encodings

How do I convert an image to Base64?

Pick Encode, then File, and drop the image. The Base64 shows at once, ready to copy or download as a .txt file. Tick the data URL box to get it with data:image/png;base64, in front, so you can paste it into an img src or a CSS url(). Any file type works, up to 5 MB, and it is read in your browser, not uploaded.

Is Base64 encryption?

No. Base64 has no key, and anyone can decode it in one step, on this page or anywhere else. Never use it to hide a password or a secret.

Why is Base64 longer than the original?

Because every 3 bytes turn into 4 characters, the result is about 33% longer. Hello World! is 12 bytes and encodes to 16 characters: SGVsbG8gV29ybGQh.

Sources: IETF, RFC 4648: Base16, Base32 and Base64 encodings

How do I decode a URL-safe Base64 string?

Paste it in Decode as it is. URL-safe Base64 is the same encoding with - in place of + and _ in place of /, so the text can sit in a link or file name. RFC 4648 calls it base64url, and JSON Web Tokens use it with the = padding left off. This tool decodes both forms and adds missing padding back; when encoding, it writes standard Base64.

Sources: IETF, RFC 4648: Base16, Base32 and Base64 encodings

How do I convert Base64 to PDF?

Pick Decode, paste the Base64 and click Download .pdf file. The tool knows it is a PDF from its first bytes, %PDF-, and a data:application/pdf;base64, prefix in front is fine. PNG, JPEG, GIF, WebP and ZIP are found the same way; other data that is not text downloads as a .bin file. The file is built in your browser and never uploaded.

How do I check if Base64 is a valid PDF?

Paste it in Decode. If the first bytes are %PDF-, the tool says "This Base64 is a PDF file" with its size and offers a .pdf download. Base64 of a PDF usually starts with JVBERi0, which is %PDF- written in Base64. This checks the start of the file only, so a PDF that is cut off or damaged further in can still be named as a PDF. If nothing is named, it is text or another file type.

Does it handle Urdu, accents and emoji?

Yes. Text is turned into UTF-8 bytes before encoding, so اردو, café and emoji decode back exactly. JavaScript's built-in btoa function fails on these characters, which is why some quick scripts break on them.

Is my text sent anywhere?

No. Encoding and decoding run in your browser, and nothing is uploaded or saved.