Base64 Encode / Decode
Convert text or files, repair Base64 padding, choose charsets, and process separate lines locally.
Drop a file here or browse
Max 10 MB · Any file type
Runs locally in your browser. Nothing is uploaded or sent to a server.
Select Encode and enter text to get Base64, or select Decode and paste Base64 to recover text or downloadable bytes. Conversion updates as you type, using UTF-8 by default. Choose other text charsets, URL-safe output, MIME wrapping, or independent line processing. The decoder accepts data URI prefixes and repairs missing padding. File selection supports up to 10 MB per file. Encoding and decoding run locally in your browser without uploading your input.
Updated
Related Tools
JWT Decoder
Inspect lossless JSON, check token times, and verify signatures with local secrets or public keys.
developer-toolsJSON Formatter
Beautify or minify JSON, inspect its structure, and copy or download the result in your browser.
generatorsPassword Generator
Generate random passwords, word-based passphrases, or PINs with rules that match your destination.
developer-toolsCron Expression Parser
Explain Standard, Quartz, and AWS schedules with field details and up to eight local and UTC run times.
developer-toolsCode to Image
Style code with line highlights, diff colors and custom backgrounds; export PNG, JPG or text-based SVG.
developer-toolsMorse Code Translator
Translate text, decode local Morse audio, tap a key, or export a practice WAV.
How do you encode and decode text with a worked example?
Select Encode, leave the charset at UTF-8, and enter Hello without a newline. Base64 Output becomes SGVsbG8=. Select Decode and paste that result into Base64 Input to recover Hello. Conversion updates as you type; there is no separate conversion button.
The five input bytes are 48 65 6c 6c 6f in hexadecimal. Standard Base64 groups them into eight output characters, including one padding character. Use Swap to move the result into the opposite direction without retyping it. Selecting a direction tab clears the input instead, so copy anything you need before switching tabs.
What is Base64, and why does it make data larger?
RFC 4648 defines Base64 as a binary-to-text encoding using uppercase letters, lowercase letters, digits, and the symbols + and /. Each group of three bytes supplies 24 bits, divided into four groups of six bits. Each six-bit value selects one of 64 alphabet characters.
For standard padded output, length is 4 × ceil(byte length / 3), excluding any prefix or line breaks. The size increase approaches one third for long inputs; short inputs have proportionally more overhead. Two leftover bytes need one =, while one leftover byte needs two. Base64 does not compress data, and character count is not always byte count: a Unicode character can occupy several UTF-8 bytes.
Which output format should you choose?
| Option | Output behavior | When to use it |
|---|---|---|
| Default | Standard alphabet with padding | A consumer expecting ordinary Base64 |
| URL-safe | Uses - and _; removes trailing = | A consumer requiring unpadded Base64url |
| MIME (76 char) | Wraps output with line feeds at 76 characters | A text workflow requiring wrapped Base64 |
| Add data URI prefix | Prepends data: followed by your MIME type and ;base64, | A field expecting a complete data URI |
Base64url is described in RFC 4648 Section 5. This tool's URL-safe setting omits padding; follow your receiving system's requirements. For conventional MIME Base64, keep URL-safe off. MIME wrapping here inserts line feeds, not a complete email attachment with headers. The data URI MIME field defaults to text/plain; change it to describe your actual content rather than assuming the tool selects it automatically.
How do charsets affect Unicode and decoded text?
Encoding first converts text into bytes. UTF-8 uses TextEncoder, preserving ordinary Unicode text such as accented letters, CJK text and emoji. The other encoding choices are ISO-8859-1 (Latin-1) and UTF-16LE. Latin-1 rejects characters above U+00FF rather than silently truncating them. UTF-16LE writes each JavaScript code unit in little-endian byte order.
Decoding reverses the byte encoding, then interprets those bytes with your selected charset. Six decoding choices are available: UTF-8, ISO-8859-1, Windows-1252, UTF-16LE, UTF-16BE and ASCII. A failed UTF-8 check produces a warning and a Try ISO-8859-1 shortcut. ASCII displays a replacement character for bytes at or above 128. Changing the charset affects displayed text; downloading still preserves the original bytes.
What does the decoder repair, and which errors remain?
The decoder strips a recognized data:...;base64, prefix, removes whitespace, accepts either alphabet, and rebuilds trailing padding. This helps with payloads copied from wrapped messages. It does not recover missing data: an unpadded length with remainder one when divided by four is rejected as truncated.
An invalid character error gives a one-based position in the compact payload, after prefix and whitespace removal. That position may differ from the original pasted text. An equals sign inside the payload remains invalid; only trailing padding is rebuilt. This is a forgiving converter rather than a strict canonical-format validator, so successful decoding alone does not prove an input meets every requirement of another system.
How do file encoding, detection and downloads work?
Use Drop a file here or browse to encode any file type from its raw bytes. In Decode, the chooser accepts .b64 and .txt containing Base64 text. The file limit is 10 × 1024 × 1024 bytes, displayed as 10 MB, in either direction. Encoding options reprocess loaded bytes; the text charset setting does not reinterpret binary file input. Large results still consume browser memory.
Signature detection recognizes PDF, PNG, JPEG, GIF, WebP, ZIP, GZIP, MP3, WAV and MP4. Supported raster images can show an Image Preview. A declared data URI MIME type takes priority in the displayed analysis, but the download independently checks byte signatures. Thus a declared type is not proof of the file's actual format or validity.
A recognized PDF offers Download decoded.pdf; ZIP uses decoded.zip. Without a recognized signature, downloading uses decoded.bin, even when Decoded Text is readable. Rename it if appropriate. The download saves exact decoded bytes, avoiding replacement characters introduced by text display. For byte inspection, Hex Dump groups 16 bytes per row alongside offsets and printable ASCII.
When should you process each line separately or decode again?
Enable Process each line separately for independent entries. Line order and empty output slots are preserved, including a trailing empty line. A failed decode leaves its slot empty and reports the source line number; valid lines continue. The list shows the first 20 errors and a remaining count. Leave this mode off for one payload wrapped across several lines: otherwise each wrapped segment is treated as separate input.
In ordinary Decode mode, Decode again appears when the decoded text contains at least 16 non-whitespace characters, matches the Base64 alphabet and passes decoding. It moves that text into the input to remove another layer. This is a heuristic, not evidence of double encoding: ordinary text can also resemble Base64.
Where is Base64 useful, and does it protect secrets?
Base64 carries binary bytes in JSON fields, data URIs and MIME email attachments. For a JSON workflow, check recovered text with JSON Formatter. Signed JWT headers and payloads use Base64url segments; use JWT Decoder for the token structure instead of pasting a whole dot-separated token here.
Encoding has no key and supplies no confidentiality. It does not replace encryption or password hashing. This tool performs conversion in browser code and reads selected files locally without uploading their contents. That local processing does not make an encoded secret safe to publish or share. Choose Base64 for representation, then apply the security controls required by the system receiving those bytes.
How to Use Base64 Encode / Decode
-
Encode or Decode
Select Encode for plain text or file bytes, or Decode for a Base64 payload. Selecting a tab clears the current input; Swap moves the output into the opposite direction instead.
-
Plain Text or Base64 Input
Enter text in Plain Text when encoding, or paste the payload into Base64 Input when decoding. Alternatively, use Drop a file here or browse: any file type for encoding, or .b64 and .txt for decoding, up to 10 MB.
-
URL-safe or Process each line separately
For encoding, choose URL-safe, MIME (76 char), Add data URI prefix, or Text charset for encoding as needed. Enable Process each line separately for independent text entries; file input and MIME wrapping are disabled in this mode.
-
Decoded Text or Hex Dump
Read Decoded Text, choose Text charset for decoding if needed, or inspect Hex Dump. For a recognized PDF, use Download decoded.pdf to save the original bytes; other download labels follow the detected file extension.