Skip to content
QueenNexa

Free tool

Base64 Encode & Decode (UTF-8, URL-Safe, Files)

Encode and decode Base64 with UTF-8 support and a URL-safe option, or turn a file into a Base64 data URI. Runs in your browser; nothing is uploaded.

Options

Assumptions and limits

  • Text is encoded as UTF-8 first. Output follows RFC 4648, with the URL-safe alphabet available.
  • The decoder accepts either alphabet, ignores whitespace and a leading data URI prefix, and accepts missing padding.
  • Files are read in your browser (up to 10 MB). Base64 output is about 33% larger than the original data.
  • Base64 is encoding, not encryption.

Runs entirely in your browser. Nothing you type or upload is sent to our servers.

How the Base64 tool works

Base64 splits data into groups of three bytes (24 bits) and writes each group as four characters, each carrying 6 bits. When the data length is not a multiple of three, = signs pad the end. This page converts text and files both ways in your browser and checks decoded input for errors.

Worked example 1: encoding text

The text Man is three bytes: 77, 97, 110, which is 01001101 01100001 01101110 in binary. Regrouped into 6-bit pieces: 010011 010110 000101 101110 = 19, 22, 5, 46, which map to T, W, F, u. So Man encodes to TWFu. One byte, such as f, becomes Zg==, and two bytes, fo, become Zm8=.

Worked example 2: the URL-safe form

The four bytes FB FF FE 3E encode to +//+Pg== in the standard alphabet. The URL-safe alphabet replaces + with - and / with _, and drops the padding, which gives -__-Pg. Both decode back to the same four bytes. Length check: 4 bytes need 4 × 8 = 32 bits, which is 6 characters of 6 bits (36 bits), and padding brings it to 8 characters.

Common problems

  • Garbled characters after decoding usually means the original text used a different encoding than UTF-8.
  • Invalid length errors mean part of the string is missing, often from a truncated copy.
  • Image data URIs work best for small icons. Large images are better served as files.

Related tools

To fingerprint text or files, use the Hash Generator. To inspect structured data after decoding, open the JSON Formatter, and to shrink an image before embedding it, try the Image Compressor & Resizer.

Frequently asked questions

What is Base64 used for?

Base64 represents binary data as plain text made of 64 safe characters, so it can travel through systems built for text, such as JSON, email, URLs and HTML. Common uses are embedding small images as data URIs, sending files in API requests and carrying tokens. It is an encoding for compatibility, and it makes data about one third larger.

Is Base64 encryption?

No. Anyone can decode Base64 instantly, with no key. It hides nothing, so never use it to protect passwords, tokens or personal data. If you need secrecy, use real encryption, and if you only need to move bytes through a text channel, Base64 is the right tool.

What is URL-safe Base64?

Standard Base64 uses the characters + and /, and pads with =, which all have special meaning in URLs and file names. The URL-safe variant swaps them for - and _ and usually drops the padding. JSON Web Tokens use it. Switch on the URL-safe option when encoding, and the decoder accepts either form automatically.

Does this handle accented letters, emoji and other Unicode?

Yes. Text is converted to UTF-8 bytes before encoding and decoded as UTF-8 afterward, so characters such as é, 日本語 and emoji round-trip correctly. The plain browser btoa function fails on these characters, which is a common source of errors. If decoded bytes are not valid UTF-8, the tool tells you and offers a download.

How do I turn a file or image into a Base64 data URI?

Use the file picker. The tool reads the file in your browser and produces its Base64 text. Tick the data URI option to add the data:type;base64, prefix, which you can paste straight into an HTML img tag or a CSS url(). Keep this for small files, because the encoded text is about 33% larger than the file.

Why do I get an invalid Base64 error?

The usual causes are a character outside the Base64 alphabet, a missing or truncated part, extra padding signs in the middle, or mixing the standard and URL-safe alphabets. The error names the first problem and its position. Spaces and line breaks are ignored, and a leading data URI prefix is stripped for you.

Is my data uploaded anywhere?

No. Encoding and decoding happen in your browser, and files are read locally. Nothing you type or choose is sent to our servers, and analytics record only that the tool was used.

Link to this tool

Found it useful? Copy a link for your page, newsletter or documentation.

Get new tools and guides by email

Optional. The tool above works without signing up.

One email every Tuesday. Free, and you can unsubscribe in one click.

More free tools

Browse all developer tools or the full list of free tools.