Auto decodes Data URLs and Base64-shaped text; otherwise it encodes raw text or file bytes.
{{ sourceModeSummary }}
{{ sourceInputHelp }}
Drop one file onto the textarea; Auto decodes Base64 text files and encodes other file bytes.
Use UTF-8 for normal web text; Latin-1 or ASCII only for legacy byte mappings.
Choose Raw bytes preview when decoded content is binary or the text charset is unknown.
On uses - and _ instead of + and /; decoding accepts either alphabet.
{{ url_safe ? 'On' : 'Off' }}
Encode padding controls trailing = signs; decode repair adds missing = when length allows.
{{ include_padding ? 'On' : 'Off' }}
{{ fix_missing_padding ? 'On' : 'Off' }}
Accepted values: no wrap, PEM 64, MIME 76, or a custom column count of 4+.
Leave off for strict validation; turn on only for copied payloads with wrappers or separators.
{{ strip_non_b64 ? 'On' : 'Off' }}
LF is typical on Unix/web targets; CRLF fits Windows or MIME handoff.
Turn on for inline assets; MIME examples: image/png, text/plain, application/json.
{{ data_url ? 'On' : 'Off' }}

      
Field Value Copy
{{ row.label }} {{ row.value }}
# Hex Dec Char Copy
{{ b.i }} {{ b.hex }} {{ b.dec }} {{ b.ch }}
No bytes

      

      
Customize
Advanced
:

Introduction:

Bytes do not always survive when they are moved through systems that expect plain text. A byte may contain a control value, part of an image, a compressed archive, a certificate, or a text character from a specific character set. Base64 gives those bytes a printable spelling, so the data can pass through text fields, configuration files, email bodies, JSON values, logs, and URLs without being changed by line endings or character conversion.

The idea is mechanical rather than secret. Base64 groups input bits, looks up printable symbols, and writes text that can later be decoded back to the same bytes. The encoded text is usually larger than the original data and is not meant to be readable by people. Its value is compatibility: it lets binary material sit in places that would otherwise reject or damage raw bytes.

Base64 contexts and decisions
Where Base64 appears Decision that changes the text Common mistake
Email bodies and PEM-style blocks Fixed-width line wrapping may be required by the surrounding format. Assuming wrapped and unwrapped strings represent different bytes.
URL tokens and filenames base64url swaps two symbols and often omits padding. Pasting standard + and / characters where a URL-safe value is expected.
Inline browser assets A Data URL needs a media type before the encoded payload. Copying only the Base64 payload when the destination expects the full data: form.
API logs and copied payloads Whitespace can be ignored, but labels and separators may need cleanup. Leaving alphabetic wrapper text in place and treating the failed decode as a bad payload.
Three input bytes become four six-bit lookup values and then four Base64 characters.

Several spellings can decode to the same bytes. Padding signs can be present or omitted when the data length is known from context. Long strings can be wrapped across lines for mail or certificate formats. The URL-safe alphabet changes only two symbols, but those two symbols matter when a value is placed in a path, query value, filename, or token.

Text adds one more layer of choice before Base64 begins. UTF-8, UTF-16LE, Latin-1, and ASCII can turn the same visible character into different byte values, so the encoded output changes even though the text looks similar. On decode, unreadable output does not always mean the Base64 is wrong; the recovered bytes may be binary data, compressed data, encrypted data, or text interpreted with the wrong character encoding.

Base64 is not encryption, compression, authentication, or malware scanning. It is reversible encoding. A token, password, private key, document, or image remains sensitive after it has been converted into printable text.

How to Use This Tool:

Choose the direction first, then match the format options to the system that will receive the encoded or decoded value.

  1. Select Encode when plain text or a file needs a Base64 representation. Select Decode when the main field already contains Base64, base64url, or a Base64 Data URL.
  2. Paste into Text to encode or Base64 to decode, or use Browse file. In encode mode, file input preserves the original bytes; in decode mode, a selected file is read as a text payload.
  3. Set Text encoding for typed text before encoding. For decode mode, choose Decoded output as UTF-8, UTF-16LE, Latin-1, ASCII, or Raw bytes preview when the content may not be readable text.
  4. Turn on URL-safe alphabet when the encoded value is headed for a URL, filename, or token field. Decode mode accepts both standard and URL-safe symbols, so this setting is mainly a format choice for new encoded output.
  5. Open Advanced for Include padding on encode, Fix missing padding on decode, Line wrapping, Line ending, and Data URL output. Use PEM 64, MIME 76, or a custom wrap count only when the destination expects fixed columns.
  6. Use Strip non-Base64 characters only for copied punctuation, whitespace, brackets, or separators. Remove alphabetic labels such as token= manually because letters are valid Base64 characters and can become part of the attempted decode.
  7. Read the main result tab first, then confirm Payload Fields for mode, byte counts, alphabet, padding, and wrapping. Use Byte Breakdown when the decoded output is binary, uses control bytes, or displays unexpected replacement characters.

Interpreting Results:

The first result tab is the value most people need to copy. In encode mode it shows Encoded Base64, or Data URL Text when Data URL output is enabled. In decode mode it shows Decoded Text or Decoded Byte Preview according to the selected output encoding.

Payload Fields explains why two outputs differ. Padding, line wrapping, URL-safe symbols, and a Data URL prefix can change the visible text without changing the decoded bytes. Byte Breakdown is the stronger check when exact byte values matter because it lists each byte by index, hexadecimal value, decimal value, and printable character when one exists.

A successful decode means the input was parseable as Base64 after the selected cleanup and padding choices. It does not prove that the recovered data is safe, trusted, unencrypted, uncompressed, or valid for the application that will consume it. If Invalid Base64 input appears, remove wrapper words first, then compare strict validation with padding repair before deciding that the payload is corrupted.

Technical Details:

Base64 operates on octets. Text must be encoded into bytes first, while selected files already provide bytes. The byte stream is split into 24-bit groups, each full group is divided into four six-bit indexes, and each index selects one symbol from a 64-character alphabet.

Short final groups are handled with zero bits for lookup and optional = padding in the displayed text. Padding is not part of the original data. It marks how many bytes were missing from the final three-byte group so a decoder can recover the original byte count without guessing.

Formula Core

For N input bytes, padded length is computed before line wrapping, Data URL prefixes, or URL-safe symbol replacement. Unpadded output removes only the trailing padding signs.

Lpadded = 4 × N 3 P = ( 3 - N mod 3 ) mod 3 Lunpadded = Lpadded - P

Five input bytes produce two four-character groups, so the padded output length is eight characters. Since 5 mod 3 = 2, the final group uses one padding sign and an unpadded variant displays seven Base64 characters.

Transformation Core

Base64 transformation stages
Stage Example Meaning
Input bytes cat as UTF-8 is 63 61 74 The visible text is no longer the authority once bytes have been chosen.
24-bit group 01100011 01100001 01110100 Three octets form one complete Base64 group.
Six-bit indexes 011000 110110 000101 110100 Each six-bit value is between 0 and 63.
Alphabet lookup Y2F0 The indexes are written with printable characters from the selected alphabet.
Base64 variant rules
Choice Rule What it changes
Standard alphabet Uses A-Z, a-z, 0-9, +, and /. Conventional Base64 for many text formats and data blocks.
URL-safe alphabet Uses - instead of + and _ instead of /. The decoded bytes are the same when all other values match.
Padding = appears only at the end, with two signs after one leftover byte or one sign after two leftover bytes. Padding can be omitted by formats that already know the data length.
Line wrapping Line breaks may be inserted at a fixed column count such as 64 or 76. Wrapping changes presentation, not the bytes recovered after whitespace is ignored.
Data URL Uses data:<media-type>;base64, before the payload. The prefix tells a browser or document context how to treat the inline bytes.

Decode Cleanup and Failure Cases

Whitespace is removed before validation. URL-safe symbols are normalized to the standard alphabet before decoding, so either alphabet can be read. Padding repair can append missing trailing = signs when the length suggests they were omitted, but it cannot repair every malformed value.

Base64 decode validation cases
Input symptom Likely cause Practical check
Missing final = Unpadded token format. Try padding repair, then confirm the decoded byte count.
Spaces or line breaks Wrapped or copied text. Whitespace is safe to ignore when the payload characters are otherwise valid.
Leading words or labels Copied wrapper text around the payload. Remove words manually because ordinary letters are valid alphabet characters.
Unreadable decoded text Binary data, compressed data, encrypted data, or the wrong output encoding. Switch to Raw bytes preview and inspect Byte Breakdown.

Privacy Notes:

The built-in text and file conversion workflow runs in the browser, so selected files are not uploaded to a conversion service for encoding or decoding. The browser still handles the material you enter: output can be copied to the clipboard, downloaded, opened as a Data URL, or preserved in page state for later restoration.

  • Do not share a page link while sensitive pasted values remain in fields that may be restored from the URL.
  • Treat decoded credentials, tokens, certificates, and private files as sensitive even when they look like ordinary text.
  • Use file input for binary data so a text editor does not change bytes before encoding.

Worked Examples:

Encoding a short UTF-8 value

With Encode, Text encoding set to UTF-8, and the text Hello, the Encoded Base64 tab shows SGVsbG8=. Payload Fields reports 5 input bytes and 8 output bytes because padded Base64 writes four characters for each three-byte group.

Preparing a URL token

Encoding user:42 with URL-safe alphabet on and Include padding on encode off produces dXNlcjo0Mg. Payload Fields should show the URL-safe alphabet and padding removed, which matches token formats that do not want trailing = signs.

Reading a complete Data URL

In Decode mode, pasting data:text/plain;base64,SGVsbG8= recovers Hello in Decoded Text. The same payload can be inspected in Byte Breakdown, where the recovered bytes are 48, 65, 6c, 6c, and 6f in hexadecimal.

Fixing a copied wrapper

A log value such as token=SGVsbG8= may fail or decode to the wrong bytes because token contains valid Base64 letters. Delete the label and keep only SGVsbG8=; use Strip non-Base64 characters only for punctuation or separators that are not part of the alphabet.

FAQ:

Does Base64 encrypt my data?

No. Base64 is reversible encoding. Anyone who has the string can decode it without a password or key, so secrets remain secrets only if the encoded text is protected.

Why did the same visible text produce different Base64?

The encoded value depends on bytes, not just visible characters. Changing Text encoding from UTF-8 to UTF-16LE, Latin-1, or ASCII changes the byte sequence before Base64 is applied.

When should I use the URL-safe alphabet?

Use it when new encoded output is going into a URL, filename, or token field that should avoid + and /. Decode mode can read both standard and URL-safe symbols.

What does padding repair fix?

Fix missing padding on decode adds trailing = signs when they appear to have been omitted. It cannot repair a payload with misplaced padding, missing data, or alphabetic wrapper text mixed into the value.

Why does strict decode reject copied text?

Strict validation rejects characters outside the Base64 alphabet after whitespace is removed. Remove copied labels first, then enable Strip non-Base64 characters only for punctuation or separators you know are not part of the payload.

Does file conversion upload my file?

For the built-in encode and decode workflow, file bytes are read in the browser and converted there. Be careful with the resulting clipboard text, downloads, opened Data URLs, and shareable page state.

Glossary:

Octet
An eight-bit byte, the unit Base64 encodes and decodes.
Base64 alphabet
The 64 printable characters used to spell six-bit values.
Padding
Trailing = signs that describe a short final byte group.
base64url
The URL and filename-safe variant that uses - and _.
Data URL
A data: address that carries a media type and inline payload.
Byte preview
A readable view of recovered bytes where printable characters are shown and non-printable bytes are marked.

References: