Base64 Encoder

Convert text to Base64, with full Unicode support.

Base64 Encoder tool

0 B
Input size
0 B
Encoded size

About the Base64 Encoder

Base64 lets text and binary data travel safely through systems built for plain text, such as email, JSON fields, data URLs and HTTP headers. This tool will base64 encode any text, handling accented letters, Urdu and other scripts and emoji correctly by encoding them as UTF-8 first: Hello becomes SGVsbG8=. Base64 makes data about a third larger and offers no protection, since anyone can decode it, so never use it to hide passwords or private information. Encoding happens in your browser, and a URL-safe alphabet and optional padding removal suit tokens and web addresses. To reverse the process, use the Base64 Decoder, and for pictures, the Image to Base64 Converter.

Unicode is handled the right way. Your text is first turned into UTF-8 bytes and then encoded, so accented letters, Urdu, Arabic, Chinese and emoji all come back unchanged when decoded. Encoders that skip that first step fail on anything beyond basic English characters, which is the problem people most often run into with other tools, usually as an error mentioning characters outside the Latin1 range.

Keep in mind that Base64 is a way of packaging data, not a lock. Anybody can reverse it in a moment, so it conceals nothing. Use it to carry data safely through systems that expect plain text, such as email bodies, JSON fields and HTTP headers, and never as a way to keep a password or personal detail secret. Base64 is an encoding, not encryption, so anyone can decode the result; never rely on it to hide passwords or private data.

How to use the Base64 Encoder

  1. Type or paste your textAnything you want to encode, short or long.
  2. Switch on URL-safe mode if neededIt swaps + and / for - and _ so the result fits safely in a web address.
  3. Watch the outputThe encoded string updates while you type, along with the size of the input and of the result in bytes.
  4. Copy the resultPress the copy button and paste the encoded value wherever it is needed, such as a config file or a request header.

Base64 Encoder features

  • Proper UTF-8 support for emoji and every script
  • Standard and URL-safe alphabets
  • Option to leave off the = padding
  • Encoding that updates as you type
  • Byte sizes of the input and the output
  • One-click copy
  • No upload and no sign-up

Common uses

  • Embedding a small icon or font directly inside CSS or HTML
  • Sending structured data through a URL parameter
  • Putting a payload into a JSON field without breaking it
  • Building a basic authentication header while testing
  • Passing text through systems that damage special characters

Base64 encoding in practice: basic authentication headers, data URIs, email attachments, secrets in configuration and Urdu text

By the FreeToolsWorld editorial team · Updated November 2026 · How we write and check our guides

Base64 is everywhere once you start noticing it: in login headers, email attachments, inline images, configuration files and API payloads. It is also widely misunderstood as a way of hiding information. This guide builds a basic authentication header, then covers when data URIs help or hurt, why email attachments grow, why configuration secrets stored in Base64 are not protected and how Urdu text survives encoding.

A worked example: a basic authentication header

An API protected with basic authentication expects the username and password joined by a colon and encoded in Base64. For the username api and the password secret123, the text api:secret123 encodes to YXBpOnNlY3JldDEyMw==, and the request carries the header Authorization: Basic YXBpOnNlY3JldDEyMw==. Anyone who sees this header can decode the password instantly, which is why basic authentication is only acceptable over HTTPS.

Data URIs for small images

A small icon can be embedded directly in HTML or CSS as a data URI, saving a separate request. Base64 makes the data about a third larger, and embedded images cannot be cached separately from the file containing them. Data URIs suit tiny icons used once; larger or repeated images are better as normal files. For SVG icons, URL-encoding the markup is often smaller than Base64.

Email attachments

Email was designed for text, so attachments travel Base64-encoded, wrapped in lines of 76 characters. A 10 MB file becomes roughly 13.3 MB in transit. This is why attachments close to an email service's size limit fail even though the file itself seems small enough. Sharing large files through a link avoids the problem.

Secrets in configuration

Some systems, including Kubernetes, store secret values in Base64. This is encoding for safe transport, not protection: anyone with access to the configuration can decode the values in seconds. Restrict who can read such configuration, and use proper encryption or a secrets manager where real protection is needed.

Files in JSON APIs

Some APIs accept documents or photos as Base64 strings inside JSON, for example when uploading identity documents. This is convenient but inflates uploads by a third and keeps whole files in memory. For large files, APIs that accept multipart uploads or direct uploads to storage are more efficient on slow mobile connections.

Urdu text

Text is converted to UTF-8 bytes before encoding, so Urdu survives the round trip. The word سلام encodes to 2LPZhNin2YU=, and decoding returns the same word. Tools that skip the UTF-8 step fail on Urdu or produce text that decodes into garbled characters elsewhere.

Newline surprises

Encoding text created with a command such as echo password | base64 includes the newline that echo adds, giving cGFzc3dvcmQK instead of cGFzc3dvcmQ=. Systems decoding that value receive the password with a newline at the end, and authentication fails mysteriously. Use echo -n, or printf, when encoding values on the command line.

Line wrapping

Some encoders wrap output every 76 characters, following the email standard, while others produce one long line. Most decoders accept both, but some strict parsers, especially in configuration files, expect a single line. Remove line breaks if a system rejects an otherwise correct value.

Choosing Base64 or something else

Use Base64 to carry binary data through text-only channels. For short codes people must read or type, Base32 is easier. For values in URLs, use the URL-safe variant or percent-encoding. For anything secret, encrypt first, then encode the encrypted bytes if a text form is needed.

Common mistakes

  • Treating Base64 as a way to hide passwords.
  • Embedding large images as data URIs.
  • Encoding values with a trailing newline.
  • Underestimating attachment size after encoding.

Related tools

To reverse the encoding, use Base64 Decoder. For human-friendly codes, try Base32 Encoder and Decoder, and for text in URLs, URL Encoder.

Encoding in code

In JavaScript, the built-in btoa function accepts only characters in the Latin-1 range and throws an error on Urdu or emoji. Converting the text to UTF-8 bytes first with TextEncoder, then encoding those bytes, works for every language. In Python, base64.b64encode(text.encode('utf-8')) does the same in one line.

Exact values matter

Base64 is case-sensitive, so abc and ABC are completely different encoded values, and a single changed character alters the decoded bytes. When comparing encoded values from two systems, copy them exactly and watch for trailing spaces, line breaks and surrounding quotes picked up during copying.

Checksums in Base64

Several systems write hash values in Base64 rather than hexadecimal, including integrity attributes on script tags and some cloud storage checksum headers. A hexadecimal digest and its Base64 form describe the same bytes but look completely different, so convert one to the other's form before comparing.

Images inside stylesheets

Background images embedded in CSS as data URIs make the stylesheet larger, and because stylesheets block rendering, every embedded image delays the first appearance of the page. Keep embedded images in stylesheets to tiny icons, and load photographs and large graphics as separate files.

Privacy

Encoding runs in your browser. Your text is not uploaded or stored.

Further reading: Base64, URL Encoding and Hashing: What Is the Difference?.

Frequently asked questions

Does Base64 encrypt my text?

No. It is a reversible format with no key or password, so anyone who sees the output can turn it back into the original in seconds. Never rely on it to protect passwords, tokens or personal information.

Why is the encoded result longer than my text?

The format spreads each group of three bytes across four characters, which inflates data by roughly a third before padding. That extra size is the cost of making binary or special characters safe to send as plain text.

What is the URL-safe variant?

The standard alphabet uses + and /, which have special meanings inside web addresses. The URL-safe variant uses - and _ in their place, so the output can be dropped into a link as it is.

What are the = signs at the end?

Base64 processes data in groups of three bytes. When the input does not divide evenly, one or two = signs fill the last group so decoders know where the data stops. Some systems prefer them removed, which this tool can do.

Can I encode a picture or a file here?

This page encodes text. To turn an image into a data URI, use the Image to Base64 Converter on this site, and consider shrinking the picture first with the Image Compressor, since encoding makes files bigger.

Is my text sent to a server?

No. The encoding uses functions built into your browser, so the text never leaves your device and nothing is stored once you close the page.