HOW-TO

How to encode to Base64

Encode text or binary to Base64 so it survives text-only transports. Free online tool plus the one-liner in each language.

Encoding to Base64 turns bytes into safe ASCII text for transports that cannot carry raw binary — data URLs, JSON, headers, and email. Here is how to do it online and in code.

Online

Paste your text into our Base64 tool, choose encode, and copy the result. Remember Base64 is not encryption — it is reversible by anyone, so never use it to hide secrets.

In code

JavaScript: btoa(str) for ASCII, or Buffer.from(str).toString("base64") in Node. Python: base64.b64encode(data). PHP: base64_encode($data). Go: base64.StdEncoding.EncodeToString(b). Use the URL-safe variant when the output goes into a URL or JWT.

Step by step

1

Open the Base64 tool and paste your text.

2

Select "encode" to produce the Base64 string.

3

Copy the result into your data URL, header, or payload.

4

Use the URL-safe variant (- and _ instead of + and /) if it goes in a URL or JWT.

Try it now — free, no signup

Use the Base64 tool in your browser. Then, when you need it at scale with an API key and higher limits, grab the full Eveses API.

FAQ

Does Base64 encrypt my data?›
No — it only re-encodes it as text. Anyone can decode it. Encrypt first if you need secrecy.
Why is the output longer?›
Base64 encodes 3 bytes as 4 characters, so output grows about 33%.

Related