Base64 encoder and decoder for text and files.
Encode text or files to Base64 and decode it back, with full UTF-8 support and URL-safe output. Nothing is uploaded.
- Text size
- 29 bytes
- as UTF-8
- Base64 size
- 40 bytes
- Overhead
- +37.9%
- Base64 adds about a third
Free and private: this tool runs entirely in your browser.Need a fast website or web app? Talk to TechnoHelp
How to use the base64 encoder & decoder
Choose a mode
Encode turns text into Base64. Decode turns Base64 or a data URL back into text or a file. File turns any file into Base64 or a data URL.
Paste text or drop a file
Text is encoded as UTF-8, so accents and emoji work. Files up to 10 MB are read on your device; images show a preview.
Set the options
Turn on URL-safe for tokens and URLs, No padding to drop the trailing = signs, or Data URL to get a data:…;base64 string for HTML and CSS.
Copy or download
Copy the result or press Ctrl / ⌘ + Enter. When decoded data is a file rather than text, download it instead. Swap sends the output back for a round trip.
What Base64 is and why it exists.
Base64 writes any bytes using 64 safe characters (A–Z, a–z, 0–9, + and /), so binary data can travel through systems built for text, like email, JSON and HTML.
The encoder takes 3 bytes (24 bits) at a time and splits them into four 6-bit numbers, each picking one of the 64 characters. That is why Base64 output is about 33% larger than the input: every 3 bytes become 4 characters. When the input doesn’t divide by 3, = signs pad the end. The alphabet and rules are defined in RFC 4648.
Base64 is encoding, not encryption
Anyone can decode Base64 without a key. Don’t use it to hide passwords, API keys or personal data; use real encryption, and HTTPS for anything sent over a network.
Standard vs URL-safe Base64.
Standard Base64 uses + and /, which have special meanings in URLs and file paths. The URL-safe variant (base64url) swaps them for - and _.
| Property | Standard (RFC 4648 §4) | URL-safe (RFC 4648 §5) |
|---|---|---|
| Characters 62 and 63 | + and / | - and _ |
| Padding | = to a multiple of 4 | Often left out |
| Safe in URLs and file names | No: + / and = need escaping | Yes |
| Common uses | Email attachments, data URLs, PEM certificates, HTTP Basic auth | JSON Web Tokens, URL parameters, file names |
The decoder here accepts both alphabets, with or without padding, and ignores spaces and line breaks, so you can paste a token or a wrapped email attachment as it is.
Data URLs: when inlining helps.
A data URL puts a whole file inside a link, so an image can live directly in your HTML or CSS.
The format is data:[media type][;base64],data, defined in RFC 2397 (see also MDN). Inlining saves a request, but the file can no longer be cached or loaded on its own.
Good for
- Tiny icons or images used once, where a separate request costs more than the extra bytes
- Self-contained files, like a single HTML page or an SVG that must carry its own images
- Small images in JSON or other text-only formats
Avoid for
- Large images: the data is a third bigger and is downloaded with the page even if the image is never shown
- Images used on many pages: a separate file is cached once, an inlined copy is downloaded again with every HTML or CSS file
- CSS that blocks rendering: inlined images make the stylesheet bigger and the page slower to appear
Frequently asked questions.
What is Base64 encoding?
Base64 is a way to write binary data as plain text using 64 characters: A–Z, a–z, 0–9, + and /. It is used to send files and other bytes through text-only channels such as email, JSON, HTML and URLs.
Is Base64 a form of encryption?
No. Base64 is an encoding, and anyone can decode it without a key. It offers no security, so never use it to protect passwords, API keys or personal data.
Why is Base64 bigger than the original?
Every 3 bytes of input become 4 Base64 characters, so the output is about 33% larger. Line breaks, as in email attachments, add a little more.
What do the = signs at the end of Base64 mean?
They are padding. Base64 works on groups of 3 bytes, and when the input length isn’t a multiple of 3, one or two = signs fill out the last group of 4 characters. Many formats, such as JSON Web Tokens, leave the padding out, and this decoder accepts Base64 with or without it.
What is the difference between Base64 and Base64URL?
Base64URL, defined in RFC 4648 section 5, replaces + with - and / with _ so the result can go in URLs and file names without escaping. It usually omits = padding too. The decoded bytes are the same.
Why does btoa fail on emoji or accented letters?
JavaScript’s btoa only accepts characters with codes up to 255 and throws an InvalidCharacterError for anything else. Convert the text to UTF-8 bytes first, for example with TextEncoder, and encode those bytes. This tool does that for you.
How do I convert an image to Base64?
Choose File mode and drop the image in, or click to choose it. Copy the raw Base64, or turn on Data URL to get a data:image/…;base64 string you can use in an img tag or CSS. The file is read in your browser and never uploaded.
Why does my decoded Base64 look like gibberish?
The data is probably a file, such as an image, PDF or ZIP, rather than text. This tool decodes text as UTF-8 and tells you when the bytes aren’t valid UTF-8, so you can download the file instead. Text saved in another encoding, such as UTF-16, can also look garbled.
From the team behind these tools
Need a faster site or a custom web app?
TechnoHelp is an independent web design and development studio. We build fast, secure and scalable websites and web apps on a modern stack.