Loading HTML to Base64 converter...

How to Convert HTML to Base64 - Step by Step Guide

Step 1

Add your HTML

Paste your HTML code into the editor, drop an .html file onto it, or pick one with Upload.

•
Upload or drop a file: the file's own bytes are encoded, up to 10 MB
•
Paste code: a whole page or just a fragment like a single table
•
Try sample: click "Sample" to load a small status page
Step 2

Let it encode

There's no button to press. About a second after you stop typing, the Base64 version appears on the right.

•
UTF-8 text: accents and emoji decode back exactly
•
Nothing rewritten: spacing, comments and numbers such as 8901240544102066246 or 00501 stay as you wrote them
•
In your browser: the HTML is never rendered on this page and never uploaded
Step 3

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.

•
Copy: puts the plain Base64 on your clipboard (no data: prefix)
•
Download: saves html-base64.txt
•
Data URI: add data:text/html;charset=utf-8;base64, in front of it yourself

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.