HTML to Base64
Paste HTML markup and get the Base64-encoded string in one click.
Last updated: May 29, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is HTML to Base64?
HTML to Base64 encodes an HTML document or fragment as a Base64 string. Common uses include embedding HTML in a data URI for an iframe src, passing HTML through an API that only accepts Base64 payloads, or storing an HTML template as a Base64 value in a configuration file.
How to Use HTML to Base64
Paste your HTML into the input.
Click "Encode to Base64".
Toggle URL-safe if needed.
Copy the output.
Common Use Cases
- Embedding an HTML snippet in an iframe srcdoc or data URI: <iframe src="data:text/html;base64,...">.
- Sending HTML content through a webhook or API that requires Base64 encoding.
- Storing an email HTML template as a Base64 value in a database or config.
Example Input and Output
Encoding an HTML fragment to Base64.
<h1>Hello World</h1>PGgxPkhlbGxvIFdvcmxkPC9oMT4=Privacy
All encoding runs in your browser. No data is sent to any server.
Frequently Asked Questions
Will angle brackets and special characters encode correctly?
Yes. Base64 encodes the raw bytes, so all characters including <, >, &, and Unicode are preserved exactly.
Can I embed the result in an iframe?
Yes: <iframe src="data:text/html;base64,PGgxPkhlbGxvIFdvcmxkPC9oMT4="></iframe> will render the HTML. Note that sandboxing rules apply.
Related Tools
Base64 Encoder/Decoder
Encode text to Base64 or decode Base64 to plain text — with URL-safe mode, auto-detect, and size stats.
Base64 to HTML
Decode a Base64-encoded string back to HTML markup. Paste the Base64 and get the raw HTML document or fragment instantly.
Text to Base64
Encode plain text to Base64 instantly. Handles UTF-8, emojis, and international characters.
CSS to Base64
Encode a CSS stylesheet to Base64 for embedding in data URIs, JSON payloads, or API requests.
HTML Beautifier
Format and beautify minified or messy HTML code.
APNG to Base64
Convert an Animated PNG (APNG) file to a Base64 string or data URI — paste directly into HTML or CSS without hosting the image.

