Base64 Encoder
Encode text or files as Base64, with full UTF-8 support and URL-safe output.
Loading tool…
Need help with this tool or found a problem? WhatsApp support Email
About the Base64 Encoder
The Base64 Encoder converts text or any file into Base64, a form of plain text that can travel safely through systems built for text. Type or paste text and the encoded result appears immediately, or choose a file to turn its bytes into a Base64 string. Options let you produce URL-safe Base64 for links and tokens, or wrap lines at 76 characters for email.
Developers use it to build HTTP authentication headers, embed small files in JSON, XML or CSS, create data URIs, and test APIs. Unlike many simple encoders, it handles Urdu, Arabic, accented letters and emoji correctly by converting text to UTF-8 first. Encoding happens entirely in your browser, so files and credentials are never uploaded.
What is Base64 encoding?
Computers store everything as bytes, but many systems such as email, URLs, JSON and HTML were designed to carry text. Some byte values would be misread or damaged by these systems. Base64, defined in the standard RFC 4648, solves this by representing any bytes using only 64 safe characters: A–Z, a–z, 0–9, + and /, with = used as padding at the end.
It works by taking 3 bytes (24 bits) at a time and splitting them into four 6-bit groups, each mapped to one of the 64 characters. That is why Base64 output is always about one third larger than the input: every 3 bytes become 4 characters. When the input is not a multiple of 3 bytes, one or two = signs pad the end.
Base64 is an encoding, not encryption. Anyone can decode it instantly without a key, so it must never be used to hide passwords or secrets. A URL-safe variant replaces + and / with - and _ so the result can be placed in URLs and file names, usually without padding.
How to use the Base64 Encoder
- Type or paste text into Text to encode (UTF-8), or click Try example. The Base64 appears instantly below.
- To encode a file instead, click Or choose a file to encode and pick any file up to 20 MB.
- Tick URL-safe alphabet if the result will go into a URL, file name or token.
- Tick Wrap lines at 76 characters if you need MIME-style output for email.
- Click Copy result or Download to save the Base64 as a text file. Reset clears everything.
After encoding a file, the message shows its original size and the size of the Base64 output, so you can see the one-third increase for yourself.
Key features and benefits
- Full UTF-8 support. Text is converted to UTF-8 bytes first, so Urdu, Arabic, Chinese, accented letters and emoji encode correctly, unlike the browser’s plain
btoa() - File encoding. Encode images, PDFs and other files up to 20 MB directly in the browser
- URL-safe option. Uses - and _ instead of + and /, and removes = padding
- MIME line wrapping. Breaks output into 76-character lines for email standards
- Live output. Text is encoded as you type
- Copy and download. Copy the result or save it as
base64.txt - Private. Nothing is uploaded; files are read with the browser’s File API on your device
Practical examples
Simple text
Hello (5 bytes) becomes SGVsbG8= (8 characters). The single = pads the last group because 5 is not a multiple of 3. Pakistan becomes UGFraXN0YW4=.
HTTP Basic authentication
An API expects a header in the form Authorization: Basic … where the value is Base64 of username:password. Encoding user:pass gives dXNlcjpwYXNz. Remember this is not secure on its own; Basic authentication must always be used over HTTPS.
URL-safe output
The text <<???>> encodes to PDw/Pz8+Pg==, which contains / and + characters that cause problems in URLs. With URL-safe ticked the result is PDw_Pz8-Pg.
Multilingual text
The example Hello, VIPTools! سلام 👋 is 30 bytes in UTF-8 and encodes to 40 characters: SGVsbG8sIFZJUFRvb2xzISDYs9mE2KfZhSDwn5GL. Decoding it with any standard Base64 decoder returns the original Urdu and emoji.
How three letters become four characters
The word Man is three bytes: 77, 97 and 110, or 01001101 01100001 01101110 in binary. Base64 regroups those 24 bits into four groups of six: 010011 010110 000101 101110, which are the numbers 19, 22, 5 and 46. In the Base64 alphabet (A–Z = 0–25, a–z = 26–51, 0–9 = 52–61, + = 62, / = 63) those are T, W, F and u, so Man encodes to TWFu with no padding. The table shows how output length grows with input size:
| Input | Base64 length | Padding |
|---|---|---|
| 1 byte | 4 characters | == |
| 2 bytes | 4 characters | = |
| 3 bytes | 4 characters | none |
| 30 bytes | 40 characters | none |
| 1 MB file | about 1.33 MB | 0–2 characters |
Common use cases
- Web developers embed small icons or fonts in CSS and HTML as data URIs.
- API developers and testers build Basic authentication headers and send binary data inside JSON.
- DevOps engineers prepare values for configuration files and Kubernetes secrets, which store data in Base64.
- Email developers encode attachments and inline images in MIME format.
- Students learn how binary data is represented as text.
Accuracy, limitations and privacy
Encoding follows RFC 4648. Text is converted to UTF-8 with the browser’s TextEncoder before encoding, which is the standard choice for the web; if a system expects another text encoding such as UTF-16, the output will differ. URL-safe output follows the “base64url” alphabet and omits padding, which most systems accept; add = signs back if a decoder requires them.
Files are read and encoded on your device. Nothing is uploaded or stored, and the page works offline once loaded. Very large files use more memory, which is why files are limited to 20 MB.
- Base64 is reversible encoding, not encryption; do not use it to protect passwords or private data.
- Output is about 33% larger than the input, plus line breaks if wrapping is on.
- Files larger than 20 MB are not accepted, to avoid crashing the browser tab.
Tips and best practices
- Use Base64 data URIs only for small files such as icons; large embedded images slow pages down.
- Never commit Base64-encoded secrets to public code repositories — they are as readable as plain text.
- Choose URL-safe output for JWTs, query strings and file names.
- If a decoder reports an error, check for missing padding or line breaks added by email clients.
- To check what a Base64 string contains, paste it into the Base64 Decoder.
Helpful guides
Frequently asked questions
What is Base64 used for?
Sending binary data such as images or files through systems that only handle text: email attachments, data URIs, JSON APIs, authentication headers and configuration files.
Is Base64 encryption?
No. It is encoding with no key, and anyone can decode it. Use proper encryption to protect sensitive data.
Why is the output larger than the input?
Every 3 bytes of input become 4 Base64 characters, so the result is about 33% larger.
What is URL-safe Base64?
A variant that uses - and _ instead of + and /, usually without = padding, so it can be used safely in URLs and file names.
How do I Base64 encode a file?
Click “Or choose a file to encode” and select the file. The Base64 appears in the output box for you to copy or download.
Does it support Urdu and emoji?
Yes. Text is converted to UTF-8 first, so any language and emoji encode and decode correctly.
Are my files uploaded?
No. Encoding happens entirely in your browser.
Related tools and next steps
To turn Base64 back into text or a file, use the Base64 Decoder. For images, the Image to Base64 tool creates ready-to-use data URIs, and Base64 to Image reverses it. Encode text for URLs with the URL Encoder, and create fingerprints of files or text with the Hash Generator.
Related tools
All developer toolsBase64 Decoder
Decode Base64 to text, or download decoded bytes as a file.
Image to Base64 Converter
Encode images as Base64 data URIs for HTML and CSS.
Image ToolsBase64 to Image
Decode a Base64 string or data URI back into a viewable image.
Image ToolsURL Encoder
Percent-encode text for safe use in URLs and query strings.
Hash Generator
Generate MD5, SHA-1, SHA-256, SHA-384 and SHA-512 hashes.
JSON Formatter
Beautify JSON with indentation and syntax error locations.
HTML Entity Encoder
Escape special characters as HTML entities.
JSON Validator
Validate JSON and pinpoint the line and column of errors.