HTML Encoder & Decoder

Convert HTML special characters to entities and back again.

Encoding & Conversion Free, no sign-up Runs in your browser

HTML Encoder & Decoder tool

Direction

About the HTML Encoder & Decoder

Certain characters have structural meaning in HTML. An angle bracket starts a tag, an ampersand starts an entity, and quotes delimit attribute values. To display those characters as text rather than have the browser act on them, they must be written as entities: less-than becomes <, ampersand becomes &, and so on. This tool converts in both directions.

Encoding is the safety-critical direction. Any text that comes from a user and ends up inside a page must be escaped, otherwise a submitted script tag runs as code. That class of bug is cross-site scripting, and escaping is the standard defence. Use encode mode to see exactly what a value should look like once escaped.

Decoding is the everyday direction. Content pulled from feeds, exports and databases often arrives with entities still in it, so a headline reads with & in the middle of it. Decode mode turns those back into the characters they represent, including numeric entities and the full set of named ones.

How to use the HTML Encoder & Decoder

  1. Pick a directionChoose Encode to turn characters into entities, or Decode to turn entities back into characters.
  2. Paste your textAdd the HTML or the plain text you want to convert.
  3. Read the resultOutput updates as you type or as you switch direction.
  4. Copy itTake the converted text with the copy button.

Features

  • Encode the five structural characters, or every non-ASCII character
  • Decode named entities such as   and ©
  • Decode numeric entities in decimal and hexadecimal form
  • Switch direction without retyping
  • Live conversion as you type
  • Copy the result in one click

Who uses this tool

The html encoder & decoder is used by writers, developers, students, marketers and anyone else who needs the job done once without installing software. Common cases include:

  • Escaping user input before inserting it into a page
  • Showing code samples inside an HTML document
  • Cleaning up content exported from a CMS with entities left in
  • Preparing text for an HTML email template
  • Checking how a value will render once escaped

Frequently asked questions

Which characters must always be encoded?

Ampersand, less-than and greater-than in any text, plus double and single quotes when the text sits inside an attribute value. Encoding those five covers the structural cases that cause rendering problems and security holes.

Does escaping HTML make my site secure?

It removes one important class of vulnerability, but security depends on context. Text placed inside a script block, a style block or a URL attribute needs its own escaping rules. Escaping is necessary, not sufficient.

What is the difference between named and numeric entities?

Named entities such as © are readable but only exist for a defined list of characters. Numeric entities such as © work for any character by code point. The decoder understands both forms.

Why does my decoded text still show &?

The source was probably double-encoded, so the ampersand of the entity was itself encoded. Run the decode a second time to resolve it.

Should I encode non-English characters as entities?

Usually not. Modern pages served as UTF-8 display accented and non-Latin characters directly. The option to encode everything exists for legacy systems that cannot handle anything beyond ASCII.

Is my input sent anywhere?

No. Conversion happens in the page using the browser's own parser, so nothing you paste leaves your device.

If the html encoder & decoder is not quite what you need, these other free tools solve closely related problems.

URL Encoder

Escape spaces, symbols and non-ASCII characters for use in URLs.

Encoding & Conversion Use tool

Base64 Encoder

Encode any text, including emoji and accents, to a Base64 string.

Encoding & Conversion Use tool

JSON Formatter

Pretty-print and validate JSON, with the exact line and column of any error.

Developer Tools Use tool

Text Cleaner

Tidy messy pasted text: extra spaces, empty lines, breaks and special characters.

Text Tools Use tool

URL Decoder

Decode %20 and other percent escapes back into normal characters.

Encoding & Conversion Use tool