Showing code on a page
To display an HTML snippet as text rather than have it render, encode it first. The tags then appear as written.
Encode text as HTML entities in your browser so it displays as text instead of being interpreted as markup.
Maintained by Roshan.
Converts text or html to escaped html in this tab, with nothing sent anywhere.
Find related browser-local tools for nearby tasks without starting another search.
Browse all developer and data toolsWhenever text is placed inside a web page, a handful of characters are dangerous, because the browser reads them as instructions rather than content. A less-than sign starts a tag; an ampersand starts an entity; a quote can end an attribute. If a value containing any of these is dropped into a page without being escaped, at best it renders wrong and at worst it lets injected markup run - the mechanism behind a large share of cross-site scripting bugs. Encoding those characters as HTML entities is the fix: the less-than sign becomes an entity that displays as a less-than sign but is no longer read as the start of a tag. This tool escapes the five characters that matter, which is what makes arbitrary text safe to show on a page.
To display an HTML snippet as text rather than have it render, encode it first. The tags then appear as written.
Any value you concatenate into HTML should be encoded, or a stray angle bracket can break the page or inject content.
The five that HTML treats specially: & < > " and '. Everything else is left alone.
Not in a UTF-8 page. They display fine as themselves, so they are left unchanged.
Because the entities themselves contain an ampersand, which gets re-encoded. Encode raw text once only.
For HTML text and attributes, escaping these characters is the core defence. Other contexts, like scripts or URLs, need their own escaping.
Decode HTML entities back into plain text in your browser, including numeric and named forms.
Convert text into Unicode escape sequences in your browser, handling characters above the basic plane.
Percent-encode and decode URLs in your browser, choosing between encoding a value inside a URL and encoding a whole address. Shows which characters differ.