Base64 Encode
Encode text to Base64 with full UTF-8 support, switch to URL-safe Base64url, or turn a file into a data: URI — all in your browser.
How to use this tool
Steps for using the Base64 Encoder.
- Encode is selected. Type or paste text into the input panel — the Base64 output updates as you type. Click Sample for an example.
- Turn on URL-safe for Base64url:
-and_instead of+and/, without=padding — the form used in URLs, file names and JWTs. - To encode a file (up to 5 MB), click Encode a file. The output is a
data:URI ready for HTML or CSS; turn off data: URI for plain Base64. - Copy or Download the result. To check it, use Use output as input to decode it straight back.
Example
UTF-8 text with an emoji
Grüße 👋R3LDvMOfZSDwn5GLCommon use cases
- Building HTTP Basic
Authorizationheaders. - Embedding small images or fonts in HTML or CSS as
data:URIs. - Putting binary or structured data into JSON, XML, environment variables or YAML (for example Kubernetes Secrets).
- Creating URL-safe tokens and JWT segments with Base64url.
How text becomes Base64
Encoding happens in two steps. First the text is turned into bytes with UTF-8 — so ü becomes 2 bytes and 👋 becomes 4. Then every 3 bytes (24 bits) are split into four 6-bit groups, and each group picks one of 64 characters: A–Z, a–z, 0–9, + and /. If the last group is short, = padding fills it out.
That is why Base64 output is about 33% larger than the input (4 characters for every 3 bytes), and always a multiple of 4 characters long when padded. It isn't compression and it isn't encryption — anyone can decode it.
The browser's built-in btoa() only accepts Latin-1 characters and throws on anything else, so btoa("👋") fails. This page encodes UTF-8 bytes instead, which is what APIs, JWTs and email expect, so emoji and accented letters round-trip correctly.
Base64url (RFC 4648 §5) replaces + with - and / with _ and drops the padding, so the result can sit in a URL or file name without percent-encoding — the URL-safe example above shows the difference. Need to go the other way? Use Base64 Decode.
Limitations
- Files up to 5 MB.
- Base64 is not encryption: never use it to hide passwords or secrets.
- Output is about a third larger than the input — compress large data first if size matters.
Frequently asked questions
Is Base64 encryption?
No. Base64 is an encoding that anyone can reverse instantly. Use it to move data through text-only channels, not to protect it.
Why does my Base64 end with = or ==?
Padding. Base64 works in groups of 3 bytes; when the input length isn't a multiple of 3, one or two = fill the last group. URL-safe output leaves the padding off.
Why does btoa() fail on my text?
btoa() only accepts characters in the Latin-1 range. Encode the text to UTF-8 bytes first (as this page does), e.g. btoa(String.fromCharCode(...new TextEncoder().encode(text))).
How do I encode an image to Base64?
Click Encode a file and pick the image. You get a data:image/…;base64, URI to paste into an <img src> or CSS url(); turn off data: URI for the raw Base64.