Menu

HTML Encoder

Encode HTML into Base64, hexadecimal, HTML entities, Unicode escapes, or JS self-decoding output. Optionally strip comments, minify first, and encode emails and phone numbers. Preview the result live in the browser.

HTML Encoder Studio 5 Methods
Ready
🔤 Base64 encoding. Converts the entire HTML document to Base64 and prepends a tiny document.write(atob(...)) decoder. The browser renders the decoded HTML at load time. Requires JavaScript.
HTML Input 0 chars
Encoded Output 0 chars
Complete Guide to HTML Encoding

What HTML Encoding Actually Does

HTML encoding converts markup into a representation that is safe to embed in other contexts — inside a JavaScript string, a CSS rule, an XML document, or a data URI. It is a transport transformation, not security. Every method here is trivially reversible, because the browser has to decode it to render the page.

This tool gives you five encoding methods so you can match the target context:

The Five Encoding Methods

MethodOutputNeeds JS?SEO-Safe?Best For
Base64<script>document.write(atob("..."))</script>YesNoEmbedding HTML in a string or data attribute
Hexadecimal<script>document.write(String.fromCharCode(0x3C,...))</script>YesNoByte-level transport, escaping special chars
HTML Entities&#60;h1&#62;Hello&#60;/h1&#62;No✅ YesCMS fields, XML, anywhere raw HTML is stripped
Unicode Escape<script>document.write("\u003C\u0068...")</script>YesNoJavaScript string contexts, JSON-adjacent
JS Self-DecodingCharacter codes + String.fromCharCodeYesNoFully self-contained snippet that runs anywhere

Which Method Should You Use?

GoalRecommended Method
Embed HTML inside a JS stringBase64
Embed HTML in XML or an attributeHTML Entities
Keep SEO and no-JS compatibilityHTML Entities (only method that works without JS)
Send HTML through a JSON fieldBase64 or Unicode Escape
Encode only emails / phone numbersHTML Entities + Email/Phone toggles

Important Caveats

Four of the five methods require JavaScript. Base64, Hexadecimal, Unicode Escape, and JS Self-Decoding all rely on document.write at parse time. If JavaScript is disabled, blocked by Content-Security-Policy, or the user is a crawler that doesn't execute JS, the page will render blank. Only HTML Entities works without JavaScript.

What HTML Encoding Cannot Do

  • It cannot protect secrets. Anything rendered in the browser is visible in DevTools regardless of encoding.
  • It cannot stop scrapers that run JavaScript. Headless Chrome and Puppeteer see the decoded DOM.
  • It cannot replace server-side authentication. Encoding a login form does not make it secure.
  • It cannot improve performance. Every method here makes the file larger, not smaller.

Encoding vs Obfuscation vs Encryption

EncodingObfuscationEncryption
GoalSafe transportHarder to readConfidentiality
Reversible?TriviallyTrivially, with effortOnly with key
Needs key?NoNoYes
What this tool does✅❌❌

If you actually want to obfuscate JavaScript, use the JS AST Obfuscator. If you want to obfuscate CSS class names, use the CSS Class Obfuscator. HTML encoding is a different problem with a different solution.

Frequently Asked Questions

Is HTML encoding secure?
No. It's a transport transformation, not protection. Every method here is reversible, and DevTools always shows the rendered DOM regardless of encoding.
Does HTML encoding hurt SEO?
The four JS-dependent methods (Base64, Hex, Unicode, JS Self-Decoding) hide content from crawlers that don't execute JavaScript, which can hurt SEO. HTML Entities is the only method that stays SEO-safe.
Can I still style and script my page normally?
Yes, if the CSS and JS are included in the encoded payload. If you encode only a fragment, make sure the surrounding page still includes your stylesheets and scripts.
Does encoding break forms or interactive elements?
Not if the HTML is reconstructed correctly before the browser parses it. The JS-dependent methods use document.write at parse time, so the resulting DOM is identical. However, any inline event handlers or inline scripts inside the encoded HTML must also survive encoding.
Why does my page go blank after encoding?
Common causes: (1) JavaScript is disabled or blocked by CSP, (2) you encoded a full <html> document but pasted the output into a template that also wraps it, (3) the output was truncated, (4) the content contains characters that break the JS string.
Can I encode only part of a page?
Yes. Paste just the fragment you want to encode (e.g., a contact block with an email). The output is a self-contained snippet that can be inserted anywhere.
Does encoding affect email or phone links?
The Email and Phone toggles convert the visible text to HTML entities, which defeats simple scrapers that regex for @ or digit patterns. They do not change mailto: or tel: hrefs — if those are present, they remain in the source.
Is my HTML uploaded to your server?
No. Everything runs in your browser. Your code never leaves your device.
Can I download the output as a file?
Yes. Click Download to save the encoded output as encoded.html.
Which method is hardest to reverse?
All five are trivially reversible with a browser console or online decoder. JS Self-Decoding looks the most intimidating, but it's still just String.fromCharCode over an array — one line in the console to decode.
Can I decode the output back to HTML?
Yes. For Base64, use any Base64 decoder. For Entities, the browser decodes automatically. For Hex/Unicode/JS Self, run the output in a browser console and inspect the resulting DOM — that is the decoded HTML.

Related Tools

External Resources