HTML encode text

HTML encode text and get an entity-escaped string safe to drop into HTML markup. By default, the five reserved characters (&amp;, <, >, &quot;, &apos;) are escaped to their numeric character references. Switch Mode to encode every character, or to use named entities; switch Radix between decimal and hex.

Input
Line 1:1 LF cloud_done Saved locally
Result HTML Encode
0 lines 0 chars

HTML entity encoding, three modes, two radixes

HTML encoding replaces characters that have meaning inside markup with character references so the browser renders them as text instead of parsing them as HTML. The five reserved characters are &amp;, <, >, &quot;, and &apos;. In default mode, only those five are escaped; every other character passes through unchanged.

Switch Mode to All Letters to escape every codepoint as a numeric reference, which is useful for obfuscation or for embedding text inside a context where you want the browser to never confuse it with markup. Switch to Named Entities to use the five readable names (&amp;, <, >, &quot;, &apos;) instead of numeric references for the reserved set.

The Radix dropdown picks the numeric format. Decimal produces references like &#65;; Hex produces &#x41;. Both forms are valid HTML5 and render identically. Toggle Skip Newlines off if you want literal \n and \r bytes to be encoded too (default leaves them as line breaks for readability).

How to use html encode text

  1. 1Paste or type your HTML or plain text into the input panel.
  2. 2The entity-escaped result appears in the output panel as you type.
  3. 3Pick Mode: reserved-only (default), all characters, or named entities.
  4. 4Pick Radix: decimal (&#65;) or hex (&#x41;).
  5. 5Toggle Skip Newlines to keep or escape literal line breaks.

Keyboard shortcuts

Drive TextResult without touching the mouse.

Shortcut Action
Ctrl FOpen the find & replace panel inside the input Plus
Ctrl ZUndo the last input change
Ctrl Shift ZRedo
Ctrl Shift EnterToggle fullscreen focus on the editor Plus
EscClose find & replace, or exit fullscreen
Ctrl KOpen the command palette to jump to any tool Plus
Ctrl SSave current workflow draft Plus
Ctrl PRun a saved workflow Plus

What this tool actually does

Default reserved-only mode escapes the five HTML special chars

In default mode, only &amp;, <, >, &quot;, and &apos; are escaped. Every other character (letters, digits, accented characters, emoji) passes through unchanged. The current Radix picks numeric form.

Mode = All Letters escapes every codepoint

Switches to escaping every character via numeric reference. Hello becomes &#72;&#101;&#108;&#108;&#111; in decimal, or &#x48;&#x65;&#x6C;&#x6C;&#x6F; in hex. Useful for obfuscation or strict-context embedding.

Mode = Named Entities uses readable names

Switches the five reserved characters to their named forms (&amp;, <, >, &quot;, &apos;). Other characters pass through. Use this when you want HTML that reads naturally in source view.

Radix picks decimal or hex numeric form

Decimal produces &#65;; hex produces &#x41;. Both are valid HTML5 and render the same character. Hex is more compact for high codepoints; decimal is more readable for ASCII.

Skip Newlines preserves line breaks in All mode

On by default. Leaves literal \n and \r bytes unencoded so the rendered HTML keeps its line layout. Turn it off to encode line breaks as &#10; or &#x0A;. Has no effect in reserved-only or named modes.

Worked example

Default mode, decimal radix: only the five reserved characters are escaped, the alphanumerics pass through. Switch Mode to Named Entities for <p>Hello &amp; welcome!</p>.

Input
<p>Hello & welcome!</p>
Output
&#60;p&#62;Hello &#38; welcome!&#60;/p&#62;

Settings reference

Behaviour Effect on output
Mode = HTML Reserved Only Default. Only &amp; < > &quot; &apos; are escaped, in the chosen Radix.
Mode = All Letters Every character escapes to a numeric reference, in the chosen Radix.
Mode = Named Entities The five reserved characters use named forms (&amp;, <, etc.); other characters pass through.
Radix = Decimal Numeric references take the form &#65;.
Radix = Hex Numeric references take the form &#x41;. Both forms render identically in browsers.
Skip Newlines On by default. In All Letters mode, leaves \n and \r as literal line breaks. Off encodes them too.
Alphanumerics in default mode Pass through unchanged. Accented characters and emoji also pass through.

FAQ

Which mode should I use for safely embedding user input?
Use the default HTML Reserved Only mode with Decimal or Hex radix. That escapes the five characters that affect HTML parsing and leaves everything else alone, which is what every standard library does.
What is the difference between named entities and numeric references?
They render identically in browsers. Named entities (&amp;, <) read better in source view; numeric references (&#38;, &#60;) work for any character including ones that have no name. HTML5 has hundreds of named entities; this tool emits only the five reserved ones in named mode.
Why does the apostrophe escape to &#39; by default?
In default and All Letters modes, the apostrophe escapes to its numeric reference (&#39; decimal or &#x27; hex) for compatibility. Switch to Named Entities mode to get &apos; instead, which is HTML5-only and not supported in HTML4 / XHTML1.
Does it escape line breaks?
Only in All Letters mode with Skip Newlines turned off. By default, \n and \r pass through as literal whitespace, which keeps the rendered output readable.
Is the input sent anywhere?
No. Encoding runs entirely in your browser. Nothing is uploaded, nothing is logged.