SwiftVecto SwiftVecto SwiftVecto

Search Results

No matching tools found

Try searching with a different keyword or browse one of our tool categories.

↑ ↓ Navigate Enter Open Esc Close

HTML Encoder / Decoder

Encode HTML special characters into safe entities or decode HTML entities back into readable text. Work with named, decimal and hexadecimal entities directly in your browser.

Encode or Decode HTML

Convert HTML-sensitive characters into entities or decode HTML entities back into readable text directly in your browser.

Operation
Entity Style
Characters to Encode

Current Method

Encodes selected HTML-sensitive characters using familiar HTML entities.

0 characters 0 bytes
0 characters 0 bytes

Shortcut: Ctrl/Cmd + Enter to convert

Conversion Details

Review the selected operation and the size of the current input and output.

Operation

Encode

Entity Style

Named Entities

Input Bytes

0

Output Bytes

0

HTML Entity Reference

Common HTML-sensitive characters and their named, decimal and hexadecimal representations.

Character Named Decimal Hexadecimal
& & & &
< &lt; &#60; &#x3C;
> &gt; &#62; &#x3E;
" &quot; &#34; &#x22;
' &#039; &#39; &#x27;

Example: Displaying HTML as Text

If you want a browser to display HTML source rather than interpret it as markup, the HTML-sensitive characters need to be escaped.

Original HTML

<div class="notice">Tom & Jerry</div>

Encoded Source

&lt;div class=&quot;notice&quot;&gt;Tom &amp; Jerry&lt;/div&gt;

HTML Encoding vs URL Encoding

The same character can require a completely different representation depending on where it is used.

Original HTML URL Component
& &amp; %26
< &lt; %3C
> &gt; %3E

How Double HTML Encoding Happens

Encoding content that has already been escaped can produce another layer of entities.

Original

<

Encoded Once

&lt;

Encoded Twice

&amp;lt;

HTML Escaping in Laravel Blade

Blade normally handles HTML escaping for ordinary output automatically.

Escaped output

{{ $value }}

Blade escapes HTML-sensitive output by default.

Raw output

{!! $value !!}

Raw output should only be used with content that is trusted or appropriately sanitized.

HTML Encoding Is Context-Specific

Correct output escaping is an important web security measure, but different contexts require different treatment.

HTML text, HTML attributes, URLs, JavaScript and CSS are not interchangeable contexts. Production applications should use the escaping mechanisms provided by their framework for the actual output location.

Encoding Is Not the Same as HTML Sanitization

HTML encoding makes selected characters appear as text. Sanitization is a different process that inspects markup and removes or restricts unsafe elements, attributes or values.

Decoded untrusted HTML should not be inserted directly into the page using unsafe DOM APIs without appropriate sanitization.

Private Browser-Based HTML Conversion

HTML encoding and entity decoding happen directly inside your browser.

  • No file upload is required.
  • Your input does not need to be sent to SwiftVecto's server.
  • Named and numeric entity conversion is performed locally.
  • Decoding uses browser HTML parsing behaviour without rendering the decoded markup into the page.

How to Encode and Decode HTML Entities

Use the SwiftVecto HTML Encoder / Decoder to escape characters that have special meaning in HTML or convert HTML entities back into readable characters. Choose between named entities, decimal numeric entities and hexadecimal numeric entities depending on the output you need.

Overview

HTML uses certain characters as part of its markup syntax. Characters such as <, >, &, double quotes and single quotes may therefore need to be escaped when they are intended to appear as text rather than markup. HTML entities provide representations such as &lt;, &gt;, &amp; and &quot;. HTML also supports numeric character references such as &#60; and hexadecimal character references such as &#x3C;. Encoding is especially useful when displaying code examples or user-provided text without allowing markup characters to be interpreted as HTML. Decoding performs the reverse operation and converts recognised entities back into their corresponding characters. HTML encoding is context-specific and should not be confused with URL encoding, Base64 encoding or encryption.

Benefits

Encode HTML special characters safely.
Decode HTML entities back into readable text.
Convert < into &lt;.
Convert > into &gt;.
Convert & into &amp;.
Encode double quotation marks.
Encode single quotation marks.
Use named HTML entities for common special characters.
Generate decimal numeric character references.
Generate hexadecimal numeric character references.
Decode named HTML entities.
Decode decimal entities such as &#169;.
Decode hexadecimal entities such as &#x00A9;.
Handle Unicode characters.
Choose which common HTML-sensitive characters should be encoded.
Copy converted output immediately.
Swap encoded and decoded content for reverse testing.
Inspect input and output character counts.
Useful when displaying HTML source as text.
Useful when debugging CMS, API and database content.
No file upload is required.
Designed to perform encoding and decoding directly inside the browser.

How It Works

Choose whether you want to encode or decode.

When encoding, choose the entity style required for the output.

Named Entity mode uses familiar HTML entities for supported characters, such as &lt;, &gt;, &amp; and &quot;.

Decimal Entity mode represents encoded characters using decimal Unicode code points such as &#60;.

Hexadecimal Entity mode represents encoded characters using hexadecimal code points such as &#x3C;.

Choose which HTML-sensitive characters should be escaped when using selective encoding.

Paste or type the source content into the input area.

The browser converts characters into the selected entity representation.

When decoding, recognised named and numeric HTML entities are converted back into characters.

The result can be copied or swapped back into the input for reverse testing.

Normal interactive processing happens locally in the browser.

How to Use This Tool

  1. 1
    Choose Encode to convert characters into HTML entities or Decode to restore entities to text.
  2. 2
    When encoding, choose Named, Decimal or Hexadecimal entities.
  3. 3
    Select the characters you want encoded.
  4. 4
    Paste or type your text or HTML source into the input area.
  5. 5
    Run the conversion or allow the browser interface to update automatically.
  6. 6
    Review the output.
  7. 7
    Copy the converted value when required.
  8. 8
    Use Swap to place the output back into the input and reverse the operation.
  9. 9
    Use Clear to start another conversion.

Helpful Tips

  • Encode & before other HTML-sensitive characters when implementing escaping manually, otherwise newly created entity ampersands can accidentally be escaped again.
  • In production applications, prefer trusted framework escaping functions rather than manually replacing characters yourself.
  • Laravel Blade {{ }} output is escaped automatically by default.
  • Blade {!! !!} output is not escaped and should only be used when rendering HTML that is known to be safe.
  • Use &lt; and &gt; when you want HTML tags to appear visibly as text rather than being interpreted as markup.
  • Use &amp; when an ampersand needs to appear literally in HTML text.
  • Quotes often require special attention when data is inserted into HTML attributes.
  • The correct escaping strategy depends on the output context. HTML text, HTML attributes, JavaScript and URLs do not use identical escaping rules.
  • HTML entity encoding is not encryption.
  • Encoded content can be decoded back into the original characters.
  • Do not confuse &amp; with URL encoding %26.
  • Do not repeatedly encode content unless double encoding is intentional.
  • If &lt; becomes &amp;lt;, the content has usually been HTML encoded more than once.
  • Numeric entities can represent characters even when a convenient named entity does not exist.
  • Hexadecimal character references use x after &#, for example &#x3C;.

Common Uses

Display an HTML snippet on a documentation page without rendering it.

Encode user-supplied text before inserting it into HTML.

Decode content received from a CMS that contains HTML entities.

Convert &amp; back into an ampersand.

Convert &lt;div&gt; back into <div>.

Generate decimal numeric entities for special characters.

Generate hexadecimal HTML character references.

Inspect encoded text returned by an API.

Debug double-encoded HTML entities.

Escape quotation marks used within HTML attributes.

Convert Unicode symbols into numeric HTML entities.

Compare HTML escaping with URL encoding while developing a web application.

Worked Examples

The following examples demonstrate how this tool can be used in realistic scenarios.

Displaying an HTML Tag as Text

The source <strong>Hello</strong> can be encoded as &lt;strong&gt;Hello&lt;/strong&gt;. A browser displaying that encoded value as HTML text shows the tag characters rather than creating a strong element.

Encoding an Ampersand

The text "Research & Development" becomes "Research &amp; Development" when the ampersand is encoded using its named HTML entity.

Decoding HTML Entities

The input Tom &amp; Jerry decodes to Tom & Jerry because &amp; represents an ampersand character.

Decimal Numeric Entity

The less-than character < has Unicode code point 60 in decimal, so it can be represented as &#60;.

Hexadecimal Numeric Entity

The less-than character < has hexadecimal code point 3C, so it can be represented as &#x3C;.

Detecting Double Encoding

If &lt; becomes &amp;lt;, the ampersand belonging to the original entity has been encoded again. Decoding once produces &lt;, while decoding a second time produces <.

Common Mistakes

Avoid these common mistakes to achieve the most accurate results.

  • Confusing HTML encoding with URL encoding.
  • Assuming HTML encoding encrypts content.
  • Encoding content more than once and producing values such as &amp;lt;.
  • Decoding repeatedly without knowing how many encoding layers were applied.
  • Failing to encode an ampersand when it should be displayed literally.
  • Using HTML escaping when the actual output context is JavaScript.
  • Using HTML escaping when the actual output context is a URL parameter.
  • Rendering untrusted HTML using Blade {!! !!} output.
  • Attempting to secure arbitrary HTML simply by replacing < and >.
  • Assuming entity encoding sanitizes malicious HTML in every context.
  • Forgetting that HTML attribute contexts can have different escaping requirements from ordinary text nodes.
  • Treating HTML entity decoding as safe sanitization.
  • Encoding quotation marks unnecessarily when the target context does not require them.
  • Assuming every Unicode character has a convenient named HTML entity.
  • Manually maintaining a huge entity mapping when browser or framework parsers can perform standards-aware decoding.

Glossary

Definitions of the most important terms used by this tool.

HTML Entity

A textual representation of a character in HTML, commonly beginning with & and ending with ;.

HTML Encoding

The process of replacing characters that may be interpreted specially by HTML with safe entity or character-reference representations.

HTML Decoding

The process of converting recognised HTML entities and numeric character references back into their corresponding characters.

Named Entity

An HTML character reference identified by a name, such as &amp;, &lt;, &gt; or &quot;.

Numeric Character Reference

An HTML representation using the Unicode code point of a character, such as &#169; for ©.

Decimal Entity

A numeric HTML character reference containing a decimal Unicode code point, such as &#60; for <.

Hexadecimal Entity

A numeric HTML character reference containing a hexadecimal Unicode code point, such as &#x3C; for <.

Escaping

Representing potentially special syntax characters in a form where they are interpreted as data rather than markup or code.

Unescaping

Restoring escaped or encoded representations to their original characters.

&amp;

The named HTML entity representing an ampersand character (&).

&lt;

The named HTML entity representing the less-than character (<).

&gt;

The named HTML entity representing the greater-than character (>).

&quot;

The named HTML entity representing a double quotation mark (").

Unicode Code Point

A numeric identifier assigned to a Unicode character and used by numeric HTML character references.

Double Encoding

Encoding content that has already been encoded, often producing strings such as &amp;lt; instead of &lt;.

HTML Sanitization

The process of removing or restricting unsafe markup. Sanitization is different from ordinary HTML entity encoding.

Output Context

The location where data will be inserted, such as HTML text, an HTML attribute, JavaScript, CSS or a URL. Different contexts can require different escaping strategies.

Frequently Asked Questions

What is HTML encoding?

HTML encoding replaces characters that have special meaning in HTML with entity or character-reference representations so they can be treated as text rather than markup.

What is HTML decoding?

HTML decoding converts recognised entities such as &amp;, &lt; and numeric character references back into their corresponding characters.

What does &amp; mean?

&amp; is the named HTML entity representing an ampersand character.

What does &lt; mean?

&lt; represents the less-than character <.

What does &gt; mean?

&gt; represents the greater-than character >.

What does &quot; mean?

&quot; represents a double quotation mark.

How do I display HTML code without rendering it?

Encode markup-sensitive characters such as < and > so tags appear as text. For example, <div> can be represented as &lt;div&gt;.

What is &#60;?

&#60; is a decimal numeric character reference for the less-than character because its Unicode code point is 60 in decimal.

What is &#x3C;?

&#x3C; is the hexadecimal numeric character reference for the less-than character.

What is the difference between named and numeric HTML entities?

Named entities use readable names such as &amp;, while numeric character references use a decimal or hexadecimal Unicode code point such as &#38; or &#x26;.

Can numeric entities represent Unicode characters?

Yes. Numeric character references can represent Unicode code points supported by HTML.

Is HTML encoding the same as URL encoding?

No. HTML encoding addresses HTML markup syntax while URL encoding addresses URI syntax. An ampersand may become &amp; in HTML but %26 when encoded as a URL component.

Is HTML encoding the same as Base64?

No. HTML encoding escapes markup-sensitive characters. Base64 is a binary-to-text representation used for entirely different purposes.

Is HTML encoding encryption?

No. HTML entity encoding is easily reversible and should not be used to hide or protect sensitive information.

What is double HTML encoding?

Double encoding happens when already encoded content is encoded again. For example, &lt; can become &amp;lt; because the ampersand from the first entity is escaped on the second pass.

How do I fix &amp;lt;?

If the content is genuinely double encoded, decoding it once produces &lt; and decoding it again produces <. You should first confirm how many encoding layers were intentionally applied.

Does HTML encoding prevent XSS?

Correct contextual output escaping is an important defence against cross-site scripting, but security depends on where the value is inserted. HTML text, attributes, URLs, JavaScript and CSS are different contexts, and encoding alone should not be confused with complete HTML sanitization.

Does Laravel Blade encode HTML automatically?

Normal Blade output using {{ }} escapes HTML by default. Raw Blade output using {!! !!} does not perform that normal escaping and therefore requires trusted or appropriately sanitized content.

Should I manually HTML encode database values before saving them?

Usually applications store the original data and perform the correct contextual escaping when rendering output. Pre-encoding stored data can lead to double encoding and makes reuse in other contexts more difficult.

Should every quotation mark be HTML encoded?

Not necessarily. The characters that need escaping depend on the output context. Quotes are especially significant when untrusted data is inserted into HTML attributes.

Can this tool decode named HTML entities?

Yes. The browser implementation is designed to use HTML parsing behaviour capable of decoding recognised named entities.

Can this tool decode decimal entities?

Yes. Decimal numeric character references such as &#169; can be converted back into their Unicode characters.

Can this tool decode hexadecimal entities?

Yes. Hexadecimal character references such as &#x00A9; can be converted back into their corresponding Unicode characters.

Does SwiftVecto send my HTML input to the server?

The interactive HTML Encoder / Decoder is designed to perform normal encoding and decoding directly inside your browser.

Is the HTML Encoder / Decoder free?

Yes. SwiftVecto provides this developer utility for encoding and decoding HTML entities and character references.

Things to Know

  • The tool supports both encoding and decoding operations.
  • Named entity encoding is primarily intended for common HTML-sensitive characters.
  • Decimal numeric mode uses Unicode code points expressed in base 10.
  • Hexadecimal numeric mode uses Unicode code points expressed in base 16.
  • Decoding should support recognised named entities and numeric character references.
  • Selective encoding options allow users to control common characters such as &, <, >, double quotes and single quotes.
  • HTML encoding is context-specific and is not interchangeable with URL encoding.
  • HTML encoding does not encrypt the input.
  • Normal interactive conversion is intended to happen directly inside the browser.

Disclaimer

HTML entity encoding is not a substitute for complete application security or HTML sanitization.

Correct escaping depends on the output context in which data is inserted.

Developers should prefer framework-provided contextual escaping mechanisms for production application output.

Decoded HTML may contain active markup. Do not inject decoded untrusted content directly into the DOM using unsafe APIs such as innerHTML without appropriate sanitization.

Users remain responsible for validating output handling against the security requirements of their application.

We use cookies

SwiftVecto uses cookies to improve your experience and support free tools through advertising. Privacy Policy · Cookie Policy