Base64 Encoder
Encode and decode Base64 strings β supports text, files, images and URL-safe mode.
Output will appear here
Start typing to see live output
All encoding happens locally in your browser β your data never leaves your device.
Base64 is a binary-to-text encoding that represents any sequence of bytes using 64 printable ASCII characters (AβZ, aβz, 0β9, + and /), with = used as padding. Every 3 input bytes become 4 output characters, so encoded data is about 33% larger than the original. This tool encodes text or files to Base64 and decodes Base64 back to text.
Text is converted to UTF-8 bytes before encoding, so accented letters, CJK characters and emoji survive the round trip β plain btoa() in JavaScript throws on those. When decoding, the resulting bytes are read back as UTF-8 text.
The URL-safe option uses the base64url alphabet from RFC 4648 (- and _ instead of + and /) and drops the = padding. That is the form used in JWT segments, so if you are looking at a token, the JWT decoder splits and decodes all three parts for you. For putting arbitrary text into a query string, percent-encoding with the URL encoder is usually the better fit.
Base64 is an encoding, not encryption: anyone can decode it. To share text that only the recipient can read, use an end-to-end encrypted private note instead.
- Choose Text or File / Image in the toolbar.
- In Text mode, pick Encode or Decode, then type or paste into the input panel. The output updates as you type.
- Select Standard or URL-safe to match what the receiving system expects. In File mode, set this before loading the file, because the file is encoded at the moment it is read.
- In File mode, drop a file onto the drop zone or click it to browse. The Base64 output appears along with the original size, encoded size and overhead.
- Copy the result with the copy button, or use Swap (Text mode) to move the output into the input and reverse the direction.
- Text encoding and decoding with UTF-8 handling for non-ASCII characters
- Standard (+ and /, padded) and URL-safe (- and _, unpadded) alphabets
- URL-safe decoding restores missing = padding automatically
- File and image encoding by drag-and-drop or file picker, any file type
- Image preview and an original size / encoded size / overhead readout for files
- Swap button to feed the output back in and reverse the direction
- Encoding and decoding run in the browser; input is not uploaded
Encoding ASCII text
Input: Hello, World! Output: SGVsbG8sIFdvcmxkIQ==
13 bytes become 20 characters. The last group holds only one byte, so two = padding characters are added.
Encoding UTF-8 text
Input: hΓ©llo β Output: aMOpbGxvIOKckw==
Γ© takes 2 bytes and β takes 3 bytes in UTF-8, so these 7 characters are encoded as 10 bytes.
Standard vs URL-safe
Input: <<???>> Standard: PDw/Pz8+Pg== URL-safe: PDw_Pz8-Pg
The same bytes in both alphabets: / becomes _, + becomes -, and the padding is removed.
Building a data URI from an image
Tool output: iVBORw0KGgoAAAANSUhEUgAA... Data URI: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...
File mode outputs raw Base64 only. Prepend data:<mime-type>;base64, yourself to embed the image in HTML or CSS.
Invalid Base64 string β check your input.
The input contains characters outside the selected alphabet (for example - or _ while Standard is selected), the string was truncated when copied, or the decoded bytes are not valid UTF-8 text.
Switch to URL-safe if the string contains - or _, make sure you copied the whole value, and remember that Base64 of binary files cannot be shown as text.
Encoding failed β input may contain unsupported characters.
The text contains an unpaired UTF-16 surrogate, usually half of an emoji left over from a truncated copy and paste. It cannot be converted to UTF-8.
Delete the broken character at the edge of the pasted text and paste the full string again.
The result differs from another encoder or the command line
The other side encoded different bytes. echo "hi" | base64 includes a trailing newline and gives aGkK, while the tool gives aGk= for hi. Some tools also encode text as UTF-16 or Latin-1 instead of UTF-8.
Use echo -n (or printf) on the command line and confirm both sides use UTF-8.
The page becomes slow with a large file
The whole file is read into memory and the encoded text, about a third larger, is rendered in a text area.
For files of many megabytes, use a command-line tool such as base64 instead.
Why is the Base64 output larger than the input?
Each Base64 character carries 6 bits, so 3 bytes (24 bits) need 4 characters. That is a fixed overhead of about 33%, plus up to two padding characters. File mode shows the exact overhead for the file you loaded.
When should I use URL-safe Base64?
Use it when the encoded value goes into a URL, a filename or a JWT. In standard Base64, / is a path separator, + can be read as a space in query strings, and = separates keys from values. The base64url alphabet avoids all three. Decoding in URL-safe mode converts - and _ back and re-adds the padding for you.
Can I decode Base64 back into a file or image?
No. Decoding is text-only: the decoded bytes are shown as UTF-8 text. Base64 that represents binary data, such as a PNG, is not valid UTF-8, so the tool reports an invalid input instead of producing a file.
Does the file output include the data: prefix?
No. The output is the bare Base64 string, which is what most APIs and JSON payloads expect. Add a prefix such as data:image/png;base64, when you need a data URI.
Is Base64 a way to hide or protect data?
No. It is a reversible encoding with no key, so anyone can decode it in one step. Use it to move bytes through text-only channels, not to protect secrets.
- URL Encoder/DecoderEncode text to URL format and decode URL-encoded strings with Unicode support.
- JWT DecoderDecode and inspect JWT tokens β header, payload, signature at a glance.
- Hash GeneratorGenerate MD5, SHA-1, SHA-256 and SHA-512 hashes instantly. Real-time, fully client-side.
- HTML Escape/UnescapeEscape and unescape HTML strings β convert special characters to/from entities safely.
- XML Escape/UnescapeEscape and unescape XML strings β properly encode special characters for XML documents.
- JSON Escape/UnescapeEscape and unescape JSON strings β ensure valid JSON formatting with proper character escaping.