Base64 {{ mode==='encode' ? 'Encoder' : 'Decoder' }}
Mode: {{ modeLabel }} In {{ formatNumber(input_bytes) }} B Out {{ formatNumber(output_bytes) }} B URL-safe Wrap {{ wrap_cols }} No padding Data URL Text {{ input_encoding }} To {{ output_encoding }}
From file: {{ file_name }} ({{ formatNumber(file_bytes) }} B)
Include on encode
Fix on decode
# Hex Dec Char Copy
{{ b.i }} {{ b.hex }} {{ b.dec }} {{ b.ch }}
No bytes
Open preview:

      
:

Introduction:

Binary data is information stored as bytes that often needs to pass through text systems without confusion, and Base64 expresses those bytes as readable characters so the content survives intact.

The converter lets you move between your original text or file and its Base64 form, and it also reverses the process so you can check exact byte counts and see how padding and line wrapping affect the result.

You can view a concise preview of decoded bytes as characters and inspect a per‑byte table when needed, and you may also package Base64 as a self‑contained data string that embeds neatly in documents.

Results are shaped by the chosen text encoding and by whether padding is kept, so use consistent settings when you compare outputs across runs.

If a pasted block contains line breaks or headers from a message, enable the stripping option before decoding so characters outside the Base64 alphabet do not cause errors.

Treat sensitive material with care and prefer test samples in shared screenshots.

Technical Details:

Binary data is the quantity of interest. Each input is interpreted as a sequence of 8‑bit bytes. Base64 represents those bytes with an alphabet of sixty‑four symbols and an optional trailing padding character that preserves alignment.

The computation maps every group of three input bytes to four output characters. Padding signals when the final group has one or two bytes. A URL‑safe variant replaces + and / with - and _. Wrapping inserts line breaks at fixed column widths without changing meaning.

Results are read as text or as raw bytes. When text is selected, bytes are decoded with one of four encodings: UTF‑8, UTF‑16LE, ISO‑8859‑1 (Latin‑1), or ASCII. Choosing the right encoding matters for accented letters and symbols.

Comparability improves when you keep the same alphabet choice, padding policy, and line endings across runs. Values near group boundaries change length when padding is toggled, which is expected.

L = 4 × n3 L = L p , with p {0,1,2} if padding is omitted.
Symbols and units
Symbol Meaning Unit/Datatype Source
n Number of input bytes byte count Input
L Base64 length with padding characters Derived
L′ Base64 length without padding characters Derived
p Padding characters removed 0 to 2 Derived
Worked example

Input text “Hi” with ASCII produces two bytes: 72 and 105 (0x48, 0x69). Groups of three bytes become four Base64 characters, so two bytes yield four characters with one padding mark.

n = 2 L = 4 Encoded = “SGk=”

If padding is omitted, the visible result is “SGk”. Both forms decode to the same two bytes.

  1. Convert input text to bytes using the selected encoding.
  2. Partition bytes into groups of three and form 24‑bit blocks.
  3. Split each block into four 6‑bit values and map to the Base64 alphabet.
  4. Replace +// with -/_ for the URL‑safe variant if requested.
  5. Add = padding when the final block has one or two bytes, unless disabled.
  6. Optionally wrap output to 64 or 76 columns, using LF or CRLF line endings.
  7. For a data string, prepend data:<mime>;base64, before the Base64 text.
Variables and parameters
Parameter Meaning Unit/Datatype Typical Range Sensitivity Notes
Mode Encode or decode enum encode, decode High Swapping feeds the current output back as input.
Text encoding Byte mapping for input or output enum UTF‑8, UTF‑16LE, Latin‑1, ASCII High Controls how characters become bytes and back.
URL‑safe Safe alphabet for links boolean off or on Low Decoding accepts either alphabet.
Padding Include trailing = on encode boolean off or on Medium Affects visible length only.
Fix missing padding Auto‑add = to multiples of four boolean off or on Low Useful for compact tokens.
Wrap preset Column width for line breaks integer 0, 64, 76 or custom Low Wrapping is cosmetic.
Wrap columns Custom wrap length integer 4 to large Low Enabled when preset is custom.
Strip non‑Base64 Ignore characters outside the alphabet boolean off or on Medium Helps with pasted blocks.
Line endings Newline style for wrapped output enum LF or CRLF Low Decoding ignores newlines.
Data string Prefix with data:<mime>;base64, boolean + text Enabled with MIME type Low Auto‑fills type when encoding a file.

Units, precision, and rounding: Counts are integers. Bytes are 8‑bit units. Character counts include line breaks when wrapping is enabled. No numeric rounding is applied.

Validation and bounds
Field Type Min Max Step/Pattern Error Text Placeholder
Wrap columns number 4 step 1
Base64 input (decode) text 0 alphabet A–Z a–z 0–9 + / and = “Found non‑Base64 characters. Enable “Strip non‑Base64” in Advanced to ignore them.” Paste Base64…
File read (encode) bytes 0 “Failed to read file bytes.”
File read (decode) text 0 “Failed to read file text.”
Decoding process “Invalid Base64 content.” or “Decode failed.”
MIME type text free text image/png
I/O formats
Input Accepted Families Output Encoding/Precision Rounding
Text Unicode strings Base64 text Exact characters None
File (encode) Any readable bytes Base64 text or data string Exact bytes → Base64 None
File (decode) Text file containing Base64 Text or bytes preview Selected text encoding None
Summary Inputs and totals JSON JSON snapshot Character and byte counts None

Networking and storage: Processing occurs in the browser. No requests are made to external services. Opening a data string uses a new tab or window provided by the browser.

Performance and complexity: Encoding and decoding run in time proportional to input size. Bytes are processed in chunks to reduce peak memory during string conversion.

Diagnostics and determinism: Identical inputs with the same options yield identical outputs. Errors are reported with concise messages and byte and character totals are shown for context.

Security considerations: Treat untrusted data strings cautiously. Avoid opening unknown content. Do not paste secrets into shared environments. Padding and wrapping choices do not provide confidentiality.

  • Heads‑up ASCII replaces non‑ASCII characters with ? on encode.
  • UTF‑16LE interprets bytes in little‑endian pairs.
  • Latin‑1 maps bytes 0 to 255 directly to characters.
  • URL‑safe output changes only the alphabet, not the underlying bytes.
  • Line wrapping affects display and file size, not decoded content.
  • Whitespace is ignored when decoding if stripping is enabled.
  • Data strings require a correct MIME type for accurate previews.
  • Very large inputs may strain memory during conversion.
  • Non‑ASCII input with ASCII decoding yields garbled text.
  • Missing padding can break decoding when auto‑fix is disabled.
  • Invisible characters in pasted text can cause validation errors.
  • Unexpected wrap widths add extra newlines in the output view.
  • CRLF vs LF differences can change character counts.
  • Binary files decoded as text may show replacement symbols.
  • Clipboard limits can truncate very long copies in some environments.
  • Pop‑up blockers may prevent opening a data string preview.
  • Trailing spaces in a MIME type make data strings less portable.
  • Operating‑system encodings not listed are not available.

Privacy & compliance: Files are processed locally; nothing is uploaded. No data is transmitted or stored server‑side.

Step‑by‑Step Guide:

Base64 encoding and decoding converts bytes to readable characters and back with consistent, inspectable results.

  1. Choose the mode for encode or decode.
  2. Provide text or select a file. For encode, bytes come directly from the file.
  3. Pick the text encoding that matches your content.
  4. Set URL‑safe, padding, and wrap width as needed.
  5. For a shareable data string, enter a MIME type.
  6. Review the output and byte totals, then copy or download.

Example: Encode a small PNG file with a MIME type of image/png to get a compact data string suitable for embedding in a note.

You now have a clear, portable representation you can decode anywhere.

FAQ:

Is my data stored?

No. Processing happens in the browser and no server receives your inputs or results.

Files are handled locally.
How accurate is the size shown?

Byte counts reflect exact input and output sizes. Wrapping adds newline characters, which are included in the character count.

No rounding is applied.
Which encodings are supported?

UTF‑8, UTF‑16LE, ISO‑8859‑1 (Latin‑1), and ASCII are available. Choose the one that matches the text you expect.

Mismatched encodings produce garbled symbols.
What does “URL‑safe” mean?

It switches the alphabet to use - and _ instead of + and /. Decoding accepts either style.

Content is unchanged.
How do I decode a data string?

Paste the text that starts with data:, then decode. The prefix is ignored and only the Base64 segment is processed.

Provide a MIME type if you want to preview as a file.
Does it work without a connection?

Yes. All computation runs locally in your browser.

Opening a preview uses a new tab.
Are there any costs or licensing terms?

No pricing or licensing terms are presented here. Use in line with your organization’s policies.

Check internal guidance when sharing data.

Troubleshooting:

  • “Found non‑Base64 characters” → enable stripping and try again.
  • Garbled letters after decode → pick the correct text encoding.
  • Extra line breaks → disable wrapping or change the wrap width.
  • Token rejected by a service → switch to the URL‑safe alphabet.
  • Preview fails to open → allow the pop‑up for this site.
  • Very large inputs lag → convert in smaller chunks.

Advanced Tips:

  • Tip Use the raw‑bytes view to sanity‑check binary headers before choosing a text encoding.
  • Tip Keep wrapping off for compact tokens and on for human‑scannable blocks.
  • Tip CRLF line endings improve interoperability with legacy tools that expect Windows‑style newlines.
  • Tip Provide a precise MIME type to make data strings preview correctly in other tools.
  • Tip When toggling URL‑safe, re‑encode from the same bytes to avoid accidental edits.
  • Tip Compare byte totals rather than character counts when judging decode correctness.

Glossary:

Base64
A 64‑symbol alphabet that renders bytes as readable text.
URL‑safe Base64
A variant that uses - and _ instead of + and /.
Padding
Trailing = characters indicating partial byte groups.
Data string
A self‑contained text that starts with data:<mime>;base64,.
MIME type
A label that describes the media format of embedded content.
LF / CRLF
Line feed and carriage‑return‑line‑feed newline styles.
UTF‑8
A Unicode encoding that efficiently represents most text.
ASCII
A 7‑bit character set for basic English letters and symbols.