⭐ 0

HTML & URL Encoder / Decoder

Encode or decode with encodeURIComponent, or escape the six HTML characters this page maps.

🔒 Processed entirely in your browser — nothing you enter here is ever uploaded.

The result appears on this page after you run the tool. Nothing you enter is uploaded.

Processing... 0%
Scanning special characters
Formatting entities
Done

Result

About this tool

The mode menu starts on encode and the format menu starts on URL. URL encode calls encodeURIComponent on the whole box. The text a b becomes a%20b. A question mark becomes %3F, and a slash becomes %2F, because encodeURIComponent encodes those reserved characters. URL decode calls decodeURIComponent. A stray percent sign that is not a valid escape throws, and the output becomes Error: followed by the browser's message. The page does not try to recover a partial decode.

HTML encode does not call a browser escape helper. It replaces six characters: ampersand becomes &amp;, less-than becomes &lt;, greater-than becomes &gt;, a double quote becomes &quot;, an apostrophe becomes &#x27;, and a slash becomes &#x2F;. The text a<b> becomes a&lt;b&gt;. The text a/b becomes a&#x2F;b. Characters outside those six, including letters and spaces, are left as they are. HTML decode assigns the text to a textarea's innerHTML and reads the textarea's value back, so named and numeric entities the browser understands are decoded. That decode path is wider than the six characters the encoder writes.

While the format is URL and the mode is encode, the page also tries to read a query string. If the text has no scheme and does not start with a question mark, it is tried as a path under http://temp.com/. A text that actually contains a query fills the parameter grid with one row per name and value. Editing a cell in that grid rebuilds the encoded output. Text with no query hides the grid. The grid is not shown for HTML mode or for decode. The diff panel under the output highlights the encoded result while you are encoding, and it is hidden while you are decoding. The conversion runs as you type, and the execute button runs the same function. Nothing is uploaded. The encoder will not leave a URL's structure partly intact the way encodeURI does. If you encode a full URL with encodeURIComponent, the colon and the slashes are encoded too. Decode expects the whole box to be one component. The HTML map is those six characters only. An emoji or a character such as an accented letter is unchanged in HTML mode and percent-encoded in URL mode. Ampersand is the character to try first in HTML mode: & becomes &amp;, and a second pass encodes that result again because the ampersand in &amp; is still an ampersand. URL decode of a%20b returns a b. The grid under a query string is a convenience for editing names and values. It is not a second encoder with different rules.

Example. URL encode turns a b into a%20b. HTML encode turns a<b> into a&lt;b&gt; and a/b into a&#x2F;b. A broken percent escape in URL decode is written as Error: plus the decoder message.

Limit. URL encode is encodeURIComponent of the whole box, not encodeURI. HTML encode only maps & < > " ' and /. The parameter grid is shown only while encoding a URL that has a query.

How is a space encoded?

In URL mode, encodeURIComponent turns a b into a%20b. A question mark becomes %3F and a slash becomes %2F. The function encodes the entire box, including the punctuation of a full URL.

Which characters does HTML mode escape?

Six: & becomes &amp;, < becomes &lt;, > becomes &gt;, a double quote becomes &quot;, an apostrophe becomes &#x27;, and / becomes &#x2F;. a<b> becomes a&lt;b&gt;. a/b becomes a&#x2F;b. Other characters stay as typed.

When does the parameter grid appear?

Only in URL encode mode, and only when the text parses as a URL with a query string. A bare sentence hides the grid. HTML mode and both decode modes hide it. A decode error from a bad % sequence is written as Error: and the message.

Does HTML decode only understand those six entities?

The decoder writes the text into a textarea as HTML and reads the value back, so the browser decodes the entities it knows. The encoder on this page only produces the six replacements listed above.