Base64 Encode/Decode (Text)

Loading dropzoneโ€ฆ

Input

Output

About this Base64 encoder Online Base64 Encoder

Part of the Encode64 โ€œBase64 Studioโ€, this encoder turns text, JSON and small binary assets into Base64 strings ready to paste into headers, HTML/CSS, environment variables or test fixtures. No login, no install, and no server-side processing.

Why Use This Base64 Encoder

  • Instant Base64 encoding for text, JSON and small binary payloads
  • File support (text, images, binaries) for quick conversion into Base64 strings
  • URL-safe option for JWTs, query parameters and web-safe contexts
  • Optional line wrapping to mimic CLI tools or email / PEM formats
  • One-click copy for easy reuse in headers, configs and code
  • Responsive UI that works well on desktop and mobile
  • Encoding happens in your browser โ€” your data is not sent to a remote server

๐Ÿ”ง How Base64 Encoding Works (Step-by-Step) for base64-encoder

1

Provide the input

Paste your text, JSON or snippet into the input area, or drop a file to convert its raw bytes to Base64. The tool reads the bytes exactly as they are.

2

Convert to bytes

The encoder converts characters (like UTF-8 text) or file content into bytes. Each byte is an 8-bit value between 0 and 255.

3

Regroup bits into Base64 indices

Every 3 bytes (3 ร— 8 = 24 bits) are regrouped into 4 groups of 6 bits (4 ร— 6 = 24). Each 6-bit group is an index into the Base64 alphabet.

4

Map to Base64 characters & pad

Each 6-bit index is converted to a Base64 character. If the input is not divisible by 3 bytes, '=' padding is added so the output length is always a multiple of 4 characters.

Technical Specifications

Character Set (RFC 4648)

This encoder uses the standard Base64 alphabet defined by RFC 4648.

Range / TypeCharactersNotes
Indices 0โ€“25Aโ€“ZUppercase letters
Indices 26โ€“51aโ€“zLowercase letters
Indices 52โ€“610โ€“9Digits
Indices 62โ€“63+ /Standard Base64 symbols
Padding=Ensures output length is a multiple of 4

Size & Overhead

Base64 trades size for safety in text-only channels. Expect about one-third more data after encoding.

Original sizeBase64 size (approx.)Overhead
3 bytes4 characters~33% larger
1 KBโ‰ˆ 1.37 KB~37% including padding and newlines
1 MBโ‰ˆ 1.37 MBSame ratio at larger scales
Use Base64 when you need safe text transport (for example HTTP headers, JSON, HTML), not as a compression method.

Performance & Practical Limits

Encoding itself is fast, but large buffers can impact browser memory and responsiveness.

Payload sizeUser experienceRecommendation
A few KBInstantIdeal for headers, config snippets and test data
100 KB โ€“ 1 MBVery responsiveTypical for API payloads and fixtures
1โ€“5 MBGenerally fine on modern hardwareConsider CLI tools if you do this often
> 5โ€“10 MBMay feel slow or memory-heavy in the browserUse streaming encoders or CLI utilities

Command-Line Base64 Encoding

For large files, automation or CI workflows, use native Base64 utilities on your platform.

Linux / ๐Ÿ macOS

Encode a string

echo -n 'text' | base64

Encodes the string 'text' as Base64 without adding a newline.

Encode a file

base64 input.bin > output.b64

Reads binary data from input.bin and writes Base64 text to output.b64.

Windows / PowerShell

Encode string with PowerShell

[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("text"))

Converts UTF-8 bytes for 'text' into a Base64 string.

Encode file with certutil (CMD)

certutil -encode input.bin output.b64

Uses the built-in Windows tool to create a Base64-encoded file.

Practical Applications

Web Development & Data URIs

Inline small assets and resources directly into HTML, CSS or JavaScript.

  • Generate data:image/...;base64,... for logos, icons and small images.
  • Inline fonts or SVG content in CSS rules.
  • Store small payloads in LocalStorage as Base64 strings.
<img src="data:image/png;base64,iVBORw0KGgo...">
document.styleSheets[0].insertRule("@font-face{src:url('data:font/woff2;base64,...')}" );

API Development & Headers

Transport credentials and small payloads safely via text-only channels.

  • Build Authorization: Basic headers from username:password pairs.
  • Encode JSON payloads into Base64 for custom headers or query parameters.
  • Wrap binary blobs in JSON as Base64 strings.
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
fetch(url, { headers: { 'X-Payload': btoa(JSON.stringify(data)) } });

Testing, Fixtures & Debugging

Build stable, text-only fixtures for tests and debugging sessions.

  • Encode binary fixtures (images, PDFs) and embed them in test code.
  • Store sample payloads as Base64 strings instead of committing binary files.
  • Prototype payloads for services that expect Base64-encoded fields.
// Example: Jest test using Base64 fixture
const payload = Buffer.from(base64Fixture, 'base64');
expect(processPayload(payload)).toBeTruthy();

โ“ Frequently Asked Questions

โ“Why does Base64 use '=' padding?

Base64 groups input into blocks of 3 bytes (24 bits) and outputs 4 characters (4 ร— 6 bits). When the input length is not divisible by 3, '=' padding characters are added to indicate that the last block is shorter. The padding is part of the encoding format, not the original data.

๐Ÿ”—How do I generate URL-safe Base64?

URL-safe Base64 replaces '+' with '-' and '/' with '_', and often removes trailing '=' padding. Many libraries have a URL-safe mode. If you need to do it manually, start from standard Base64, then apply these replacements and trim '=' for your use case.

๐Ÿ”’Is Base64 encoding a security measure?

No. Base64 is a reversible **encoding** that makes binary data safe to transport as text (for example in JSON, HTML or headers). It provides no confidentiality or integrity by itself. Always use HTTPS/TLS and proper cryptography (like AES or public-key schemes) for security.

๐Ÿ“What is the maximum file size I should encode here?

This online encoder is most comfortable with payloads up to a few megabytes. Larger binaries may still work but could be slow or memory-intensive in the browser. For large files, command-line tools or streaming encoders are more robust.

Pro Tips

Performance Tip

For very small assets (< 10 KB), inlining as Base64 data URIs can reduce HTTP requests, but avoid doing this for large images or fonts.

Security Tip

Log only truncated Base64 payloads (or hashes) in production to avoid leaking sensitive content in logs.

Best Practice

If your backend expects Base64, validate and normalize input server-side to reject malformed or unreasonably large payloads.

Additional Resources

Other Tools