Base64 Encode/Decode (Text)
Input
Output
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
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.
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.
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.
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 / Type | Characters | Notes |
|---|---|---|
| Indices 0โ25 | AโZ | Uppercase letters |
| Indices 26โ51 | aโz | Lowercase letters |
| Indices 52โ61 | 0โ9 | Digits |
| 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 size | Base64 size (approx.) | Overhead |
|---|---|---|
| 3 bytes | 4 characters | ~33% larger |
| 1 KB | โ 1.37 KB | ~37% including padding and newlines |
| 1 MB | โ 1.37 MB | Same ratio at larger scales |
Performance & Practical Limits
Encoding itself is fast, but large buffers can impact browser memory and responsiveness.
| Payload size | User experience | Recommendation |
|---|---|---|
| A few KB | Instant | Ideal for headers, config snippets and test data |
| 100 KB โ 1 MB | Very responsive | Typical for API payloads and fixtures |
| 1โ5 MB | Generally fine on modern hardware | Consider CLI tools if you do this often |
| > 5โ10 MB | May feel slow or memory-heavy in the browser | Use 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' | base64Encodes the string 'text' as Base64 without adding a newline.
Encode a file
base64 input.bin > output.b64Reads 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.b64Uses 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?
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?
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?
Pro Tips
For very small assets (< 10 KB), inlining as Base64 data URIs can reduce HTTP requests, but avoid doing this for large images or fonts.
Log only truncated Base64 payloads (or hashes) in production to avoid leaking sensitive content in logs.
If your backend expects Base64, validate and normalize input server-side to reject malformed or unreasonably large payloads.
Additional Resources
Other Tools
- CSS Beautifier
- HTML Beautifier
- Javascript Beautifier
- PHP Beautifier
- Color Picker
- Sprite Extractor
- Base64 Decoder
- Csharp Formatter
- Csv Formatter
- Dockerfile Formatter
- Elm Formatter
- ENV Formatter
- Go Formatter
- Graphql Formatter
- Hcl Formatter
- INI Formatter
- JSON Formatter
- Latex Formatter
- Markdown Formatter
- Objectivec Formatter
- Php Formatter
- Proto Formatter
- Python Formatter
- Ruby Formatter
- Rust Formatter
- Scala Formatter
- Shell Script Formatter
- SQL Formatter
- SVG Formatter
- Swift Formatter
- TOML Formatter
- Typescript Formatter
- XML Formatter
- YAML Formatter
- Yarn Formatter
- CSS Minifier
- Html Minifier
- Javascript Minifier
- JSON Minifier
- XML Minifier
- Http Headers Viewer
- PDF To Text
- Regex Tester
- Serp Rank Checker
- Whois Lookup