MIME Base64
GeekFormat's online MIME Base64 formatter inserts CRLF line breaks at 76-character widths per RFC 2045, or restores multi-line MIME Base64 to a single line. Ideal for email attachment encoding, S/MIME signatures, PEM certificate handling and legacy system compatibility. Processed purely in your browser with no server uploads and one-click copy support.
Related
About MIME Base64 Formatting
MIME Base64 is a Base64 encoding display format used in email systems. MIME (Multipurpose Internet Mail Extensions) is a set of internet standards that define how non-text content (such as images, audio, video and other binary data) is transmitted in emails. Base64 encodes binary data as pure ASCII text, allowing email systems to safely transmit arbitrary binary attachments.
RFC 2045 is one of the core standards defining MIME. It specifies the wrapping format for Base64 encoded content in emails: each line must not exceed 76 Base64 characters, and the line terminator must be CRLF (\r\n). This limit originates from historical constraints of the SMTP protocol—early mail transfer agents (MTAs) imposed strict limits on single-line length, and the conservative 76-character setting ensures content can be processed correctly by all mail servers without being truncated or modified.
MIME Base64 and regular Base64 are completely identical in encoded content—the same character set (A-Za-z0-9+/), the same padding (= sign), and the same encoding algorithm. The only difference is the display format: MIME Base64 inserts CRLF line breaks every 76 characters to form multi-line text, while regular Base64 is typically a continuous single-line string. During decoding, line breaks are automatically ignored, and both formats decode to exactly the same original data.
Bidirectional conversion is the core need in MIME Base64 processing. Single line to wrapped: insert CRLF every 76 characters into a continuous Base64 string returned by an API to generate MIME format that complies with the email specification and can be embedded directly into an email body. Wrapped to single line: remove all line breaks from MIME format to restore a continuous string, which is more convenient for API request parameters, JSON fields or database storage. The two operations are inverse to each other.
CRLF (\r\n) is the line terminator sequence specified by the MIME standard: CR (Carriage Return, ASCII 13) + LF (Line Feed, ASCII 10). This is the standard line terminator for internet protocols, different from the pure LF (\n) used by Unix/Linux systems and the pure CR (\r) used by legacy Mac systems. RFC 2045 requires MIME content to use CRLF, but during restoration the tool recognizes all three line break types.
S/MIME (Secure/MIME) is the secure extension of MIME, used for digital signatures and encryption of emails. The PKCS#7 data structure produced after S/MIME signing contains Base64 encoded signature content, which needs to be wrapped per the MIME standard before being embedded in the email. PEM (Privacy Enhanced Mail) is another format that uses fixed-width Base64 wrapping, but it uses a 64-character width (RFC 1421), different from MIME's 76 characters. Both are fixed-width Base64 display formats, and understanding MIME Base64 helps with handling similar formats.
Content-Transfer-Encoding is a key field in the MIME email header that identifies the encoding method of the email body. When the value is base64, it means the body is Base64 encoded and presented in 76-character wrapped format. After the receiving email client reads this marker, it automatically decodes the wrapped Base64 back to the original data. Other common Content-Transfer-Encoding values include 7bit, 8bit and quoted-printable, with Base64 being the most common method for handling binary attachments.
This tool focuses on the formatting operations of MIME Base64—wrapping and restoration—and does not perform Base64 encoding or decoding. All processing is done locally in your browser via JavaScript, and data never leaves your device. Wrapping strictly follows the RFC 2045 standard (76 characters + CRLF), and restoration automatically handles CRLF, CR and LF line breaks. It is suitable for scenarios such as email development, S/MIME processing, protocol debugging and legacy system compatibility.
Use Cases
- Format single-line Base64 into 76-character-wide MIME email attachment format per RFC 2045
- Restore multi-line MIME Base64 to a single line for API transmission or embedding in JSON fields
- Process Base64 encoded content segments in S/MIME signed emails and adjust line break formatting
- Compatible with fixed-width Base64 output formats required by legacy systems or historical protocols
- Verify during email development and debugging that the wrapping of Base64 attachment content complies with the MIME specification
- Convert a continuous Base64 string returned by an API into wrapped format for easy pasting and display in an email body
- Reference the fixed-width wrapping logic when handling Base64 content in PEM certificates
- Scenarios in configuration files that require MIME-format Base64 (such as email gateways and SMTP relay configurations)
- Preprocess Base64 content before encoding email attachments to ensure correct wrapping width
- Unify Base64 data from different sources into the MIME standard for use in email systems
- Compare Base64 content differences before and after wrapping when troubleshooting email attachment encoding issues
- Convert between continuous Base64 output by command-line tools (such as OpenSSL) and the wrapped format required by email systems
How to Use
- Paste or type Base64 content into the input box
- Choose the conversion direction: single line to MIME wrap (76-character line breaks) or MIME wrap to single line (remove line breaks)
- The tool automatically formats the content per RFC 2045 and displays the result in real time
- Click the copy button to copy the result to the clipboard for use in email systems, API parameters or configuration files
Features
- RFC 2045 standard wrapping: strictly inserts CRLF line breaks at 76-character widths, compliant with the MIME email transmission specification
- Bidirectional conversion: supports converting single-line Base64 to MIME wrapped format, as well as restoring multi-line MIME back to a continuous single line
- Browser-local with zero uploads: all format conversions run inside your browser without going through any server, so data never leaves your device
- One-click copy: results can be copied directly to the clipboard for use in email clients, API parameters or configuration files
- Standard CRLF line endings: wrapping uses the standard CRLF (\r\n) sequence, meeting RFC 2045 requirements for MIME line terminators
- Precise 76-character wrapping: each line contains exactly 76 Base64 characters (the last line may be shorter), ensuring compatibility with all mail transfer agents
- Intelligent multi-line restore: automatically detects and removes CRLF/CR/LF line breaks from MIME format and concatenates them into a continuous Base64 string
- Email attachment compatible: output can be embedded directly into MIME email bodies and is parsed correctly by email clients such as Outlook and Thunderbird
- S/MIME signature support: the wrapped Base64 can be used in encoded content segments within S/MIME signature structures
- PEM format reference: although PEM uses 64-character wrapping, the tool's wrapping logic can help you understand and process similar fixed-width encoding formats
- Real-time preview: results of wrapping or restoring are displayed instantly as you type, with no need to click a button and wait
- Automatic input cleaning: whitespace and non-Base64 characters in the input are removed automatically, preventing interfering content introduced during copy-paste
- Large text handling: supports fast wrapping and restoring of long Base64 strings (tens of thousands of characters), completing in seconds locally in the browser
- Pure front-end implementation: built on native browser JavaScript APIs with no plugins or external services required, works offline
FAQ
Why does MIME Base64 wrap at a fixed 76 characters?
RFC 2045 specifies that MIME encoded content must not exceed 76 characters per line, in order to be compatible with the line length limits of early mail transfer agents (MTAs). The SMTP protocol historically required each line to be no longer than 1000 characters, but the MIME specification is more conservative, limiting lines to 76 Base64 characters plus the line break, ensuring all mail servers can process the content correctly.
Is the encoded content of MIME Base64 the same as regular Base64?
The encoded content is completely identical; the only difference is the display format. MIME Base64 inserts CRLF line breaks every 76 characters, while regular Base64 is usually a continuous single line. During decoding, line breaks are ignored, and both formats decode to the same original data.
Can multi-line MIME Base64 be restored to a single line?
Yes. The tool automatically detects and removes all CRLF (\r\n), CR (\r) and LF (\n) line breaks from MIME wrapped format, concatenating them into a continuous single-line Base64 string. The restored result is more convenient for API request parameters, JSON fields or configuration file transmission.
What is the relationship between PEM certificate format and MIME Base64?
PEM format (such as SSL certificates and private keys) uses 64-character-wide Base64 wrapping, slightly different from MIME's 76 characters. Both are fixed-width Base64 display formats, but they follow different standards (PEM is based on RFC 1421, MIME on RFC 2045). The tool's wrapping logic can help you understand similar formats.
What line break characters are used during wrapping?
Per RFC 2045, MIME Base64 wrapping uses CRLF (\r\n) as the line terminator. This is the standard line terminator for internet protocols, ensuring compatibility with all mail servers and transfer agents. Some systems may only use LF (\n); the tool automatically recognizes both during restoration.
Is MIME Base64 needed in S/MIME signatures?
Yes. The encoded content segments within the S/MIME (Secure/Multipurpose Internet Mail Extensions) signature structure use MIME Base64 format, and the signed PKCS#7 data needs to be wrapped at 76 characters before being embedded in the email. The tool can help generate wrapped Base64 that complies with the S/MIME specification.
Is the last line also padded to 76 characters?
No. RFC 2045 specifies that the last line can be of any length (1-76 characters) and does not need to be padded. This differs from fixed-length encodings (such as certain binary formats that require exactly 76 characters per line). The last line of MIME Base64 preserves the natural end of the original Base64 encoding.
How is Base64 padding (= padding character) handled?
Base64 encoding uses the = sign as the trailing padding character (0-2 of them). When MIME wrapping, the = sign appears at the end of the last line. The tool preserves padding unchanged; neither wrapping nor restoration modifies the actual Base64 content.
Does the tool modify the Base64 encoded content?
No. The tool only adjusts formatting (inserting or removing line breaks) and does not modify the Base64 characters themselves. The wrapped Base64 decodes to exactly the same result as the original input, so it can be used with confidence.
What happens if the input contains non-Base64 characters?
The tool automatically filters out whitespace (spaces, tabs, line breaks) and non-Base64 characters (those outside the A-Za-z0-9+/= range) from the input, keeping only valid Base64 content for processing. This prevents interfering characters from being introduced during copy-paste.
How long a Base64 string is supported?
The tool is built on browser-native JavaScript and supports fast wrapping and restoring of Base64 strings at the level of tens of thousands of characters. Even very long content (such as the Base64 encoding of large attachments) can be processed in seconds.
Can it be used to decode Base64?
This tool focuses on MIME formatting (wrapping/restoring) and does not perform Base64 encoding or decoding. For Base64 encoding and decoding, please use the Base64 encoder/decoder tools on the site. MIME formatting only adjusts the line break format of the Base64 string.
What does Content-Transfer-Encoding: base64 mean?
This is a field in the MIME email header indicating that the email body content is Base64 encoded. When the receiving email client sees this marker, it decodes the Base64 content (including the 76-character wrapping) in the body back to the original binary data. The wrapped Base64 generated by the tool can be used directly in such email bodies.
Why does Base64 in emails appear to have many line breaks?
Because the email system wraps Base64 encoded content every 76 characters per RFC 2045. This is a requirement of the MIME specification to ensure content can be transmitted correctly by all mail servers. In an email with attachments, the Base64 encoding of the attachments appears as multiple wrapped lines in the email source code.
Can this tool be used offline?
Yes. After the page loads, all functions run locally in the browser and do not require a network connection. Even without internet access, MIME Base64 wrapping and restoration work normally, and the processed data is never uploaded to any server.
Troubleshooting
Base64 decoding fails after wrapping?
MIME Base64 wrapping only inserts CRLF line breaks and does not modify the encoded content. If decoding fails after wrapping, the input itself may not be valid Base64 encoding. Please use a Base64 validation tool first to check whether the input is valid, then perform MIME formatting.
Line breaks remain in the Base64 string after restoration?
The tool automatically removes all CRLF (\r\n), CR (\r) and LF (\n) line breaks. If residue remains after restoration, the input may contain other invisible characters (such as spaces or tabs). The tool also filters these characters automatically, but if the problem persists, check the source content for special control characters.
Email client shows attachment garbled?
MIME Base64 wrapping is only one part of email encoding. If attachments appear garbled, the Content-Transfer-Encoding header may be set incorrectly, the Base64 encoding itself may be wrong, or the Content-Type may not match. Ensure the email header sets Content-Transfer-Encoding: base64 and uses the correct MIME boundary separator.
PEM certificate wrap width is incorrect?
PEM format uses 64-character wrapping (RFC 1421), while MIME uses 76-character wrapping (RFC 2045). This tool wraps according to the MIME standard (76 characters) and is not suitable for PEM certificate formatting. If you need 64-character PEM wrapping, please use a dedicated certificate tool or OpenSSL.
Glossary
- MIME
- Multipurpose Internet Mail Extensions, a set of internet standards (RFC 2045-2049) that define how non-text content is transmitted in emails, including mechanisms such as Base64 encoding, Content-Type and Content-Transfer-Encoding.
- RFC 2045
- The standard document defining the first part of MIME. It specifies the wrapping format for Base64 encoded content in emails: each line must not exceed 76 characters and must use CRLF as the line terminator.
- CRLF
- Carriage Return + Line Feed (\r\n), the standard line terminator sequence for internet protocols. RFC 2045 requires MIME Base64 wrapping to use CRLF, different from Unix's LF (\n) and legacy Mac's CR (\r).
- Content-Transfer-Encoding
- A MIME email header field that identifies the encoding method of the email body. A value of base64 means the content is Base64 encoded and wrapped at 76 characters; it is the most common encoding method for binary attachments.
- S/MIME
- Secure/Multipurpose Internet Mail Extensions, the secure extension of MIME used for email digital signatures and encryption. Base64 encoded segments within the signed content need to be wrapped per the MIME standard.
- PEM
- Privacy Enhanced Mail, a format that uses 64-character-wide Base64 wrapping (RFC 1421), commonly used for SSL certificates and private key files. It differs from MIME's 76-character wrapping.
- Base64 padding
- Base64 encoding uses = signs (0-2 of them) at the end to pad to a length that is a multiple of 4. During MIME wrapping, padding appears at the end of the last line and is not removed or modified.
- MTA
- Mail Transfer Agent, software responsible for forwarding emails between servers. Early MTAs imposed strict limits on single-line length; the MIME 76-character wrap was designed to be compatible with MTAs.
- SMTP
- Simple Mail Transfer Protocol, the foundational protocol for internet email transmission. SMTP requires each line to be no longer than 1000 characters (including CRLF); MIME's 76-character limit is more conservative.
- quoted-printable
- Another Content-Transfer-Encoding method supported by MIME, mainly used for content that is mostly ASCII text with only non-ASCII characters encoded. It is more space-efficient than Base64.
- PKCS#7
- Public Key Cryptography Standards #7, the cryptographic message syntax standard used by S/MIME. It defines the data structure for digital signatures and encryption, and the encoded content within uses MIME Base64 format.
- RFC 1421
- The standard document defining the PEM (Privacy Enhanced Mail) format. It specifies Base64 wrapping at a 64-character width, narrower than MIME's 76 characters, and is commonly used for certificate files.
MIME Base64 vs Regular Base64
The core difference between the two formats lies in display; the encoded content is completely identical:
| Aspect | MIME Base64 | Regular Base64 |
|---|---|---|
| Wrap width | 76 chars/line | Usually no wrap (single line) |
| Line terminator | CRLF (\r\n) | None (or system-dependent) |
| Standard | RFC 2045 | RFC 4648 |
| Typical use | Email attachments, S/MIME | API parameters, Data URL |
| Decode result | Same | Same |
Common Fixed-Width Base64 Formats
Comparison of wrap widths used by different standards:
| Format | Standard | Wrap width | Typical use |
|---|---|---|---|
| MIME Base64 | RFC 2045 | 76 | Email attachment encoding, S/MIME signatures |
| PEM | RFC 1421 | 64 | SSL certificates, private key files |
| Regular Base64 | RFC 4648 | No wrap | API parameters, Data URL, JWT |
MIME Content-Transfer-Encoding Methods
Common encoding transfer methods supported by MIME:
| Encoding | Suitable content | Space efficiency |
|---|---|---|
| base64 | Any binary data (images, audio/video, etc.) | ~33% expansion (3 bytes → 4 chars) |
| quoted-printable | Mostly ASCII text, small amount of non-ASCII | Only non-ASCII chars expand |
| 7bit | Pure ASCII text (no encoding needed) | No expansion |
| 8bit | Text with 8-bit characters (requires 8BITMIME support) | No expansion |
Privacy & Security
All operations of this MIME Base64 formatter are performed entirely in your browser locally via JavaScript. No input Base64 content, processing results or usage records are ever sent to any server. After the page loads, no network connection is required. All data exists only in browser memory and is automatically cleared when you close or refresh the page. There is no data upload or storage, and no risk of privacy leakage.
Authoritative References
- Secure String Comparison
- Binary Converter
- Caesar Cipher
- Morse Code Translator
- Hex Converter
- Video to Base64
- Base64 to Video
- Image to Base64
- Base64 to Image
- Text to Base64
- Base64 to Text
- File Hash Checker
- File to Base64
- Base64 to File
- Audio to Base64
- Base64 to Audio
- AES Encrypt / Decrypt
- DES Encrypt Decrypt
- Base32 Encoder Decoder
- Base58 Encode Decode
- Base64 Encode
- Base64 Decode
- Base64 Diff Checker
- Base64 Split
- Base64 Multi-line Merge
- Base64 Formatter
- Base64 Validation
- Base64 Batch Encode
- Base64 Batch Decoder
- Base64 Cleaner
- Base64 Padding Tool
- Base64 Length Statistics
- Base64 to HEX
- Base64 DataURL Converter
- Base64-Hex Converter
- Base85 Encoder
- HMAC Generator & Verifier
- PBKDF2 Key Derivation
- MD5 Hash
- SHA-256 Hash
- SHA1 Hash
- SHA512 Hash
- JWT Decode, Verify & Generate
- HTML Encode Decode
- Unicode Escape
- URL Encode
- URL Safe Base64
- MIME Base64
- Java Obfuscator
- JS Obfuscator
- PHP Obfuscator
- Python Obfuscator