How to Convert HTML to Base64 - Step by Step Guide
Add your HTML
Paste your HTML code into the editor, drop an .html file onto it, or pick one with Upload.
Let it encode
There's no button to press. About a second after you stop typing, the Base64 version appears on the right.
Copy or download it
Copy the string or save it as a text file. To check it, paste it into the Base64 to HTML decoder.
Frequently Asked Questions
How do I turn the Base64 into a data URI?
Put data:text/html;base64, in front of the string. For example, <h1>Hello</h1> encodes to PGgxPkhlbGxvPC9oMT4=, so the URI is data:text/html;base64,PGgxPkhlbGxvPC9oMT4=. If your HTML has accents or emoji, add a charset as well: data:text/html;charset=utf-8;base64,... so the browser reads the bytes as UTF-8.
What happens to accents, emoji and other non-English text?
Typed or pasted text is turned into UTF-8 bytes first and those bytes are encoded, the same as the base64 command does it. <p>José 😀</p> becomes PHA+Sm9zw6kg8J+YgDwvcD4=, which decodes back to the exact same text. Plain btoa() in JavaScript can't do this; it throws on emoji. If the editor holds half of an emoji (a broken surrogate pair), that one character is encoded as U+FFFD and the page tells you.
Does uploading a file change anything in it?
No. An uploaded file is encoded from its raw bytes, so a byte order mark, Windows CRLF line endings or an older page saved in Windows-1252 all come out exactly as they are on disk. If the file isn't UTF-8 text it isn't shown in the editor, but the Base64 still holds every byte. Files up to 10 MB can be loaded.
Is Base64 a way to hide or protect my HTML?
No. Base64 is an encoding, not encryption. Anyone who has the string can decode it in a second, for example with the Base64 to HTML page. Don't use it to hide passwords, API keys or private content.
Is my HTML sent anywhere?
No. The encoding runs in your browser, the HTML is not uploaded to our server, and nothing is kept. Reload the page and the editor starts empty.
Why is the Base64 longer than my HTML?
Base64 writes every 3 bytes as 4 characters, so the output is about a third bigger than the UTF-8 size of your markup. Accented letters take 2 bytes and most emoji take 4, which is why a short string with emoji grows more than you might expect.
Going the other way? The Base64 to HTML page decodes a string back into markup, and HTML Viewer shows what the page looks like.
Related Tools
Text to Base64
Encode plain text to Base64 format for APIs and data transmission
Base64 to Text
Decode Base64 encoded data to plain text for reading and debugging
JSON to Base64
Convert JSON data to Base64 format with validation
Base64 to JSON
Convert Base64 encoded data to JSON format with validation
XML to Base64
Convert XML data to Base64 format with validation
Base64 to XML
Convert Base64 encoded data to XML format with validation