Como funciona
Percent-encoding replaces each byte that is not an unreserved character with a percent sign followed by two uppercase hex digits. RFC 3986 splits the ASCII set into unreserved characters (A-Z, a-z, 0-9, hyphen, period, underscore, tilde) which are never encoded, reserved characters (: / ? # [ ] @ ! $ and the like) which have structural meaning and are encoded only when used as data, and everything else, which is always encoded. The space is a special case: it is legal as %20 in every context, whereas the plus sign for space is only correct inside application/x-www-form-urlencoded bodies.
Encode-component and encode-URI are not interchangeable, and mixing them up is the classic mistake. Encoded as a full URI, https://example.com/a b keeps its scheme, slashes and question mark intact and becomes https://example.com/a%20b. Encoded as a component, the same input becomes https%3A%2F%2Fexample.com%2Fa%20b, because the slashes and colon are data now. If a URL arrives at your server with %3A%2F%2F in it, something on the client called the wrong function.
HTML entity encoding is a different problem entirely. In HTML, the characters &, <, >, quote and apostrophe are structural: an unescaped < opens a tag, an unescaped & begins an entity reference, and an unescaped quote inside an attribute ends the attribute early. Escaping them turns markup into inert text. This is exactly the mechanism that stops cross-site scripting — a comment containing a script tag is displayed as characters rather than executed — which is why every template engine escapes by default and why bypassing that default with a raw-HTML helper is so often the source of a vulnerability.
The decoder side is stricter than most. A percent sign not followed by two hex digits is not a decodable sequence, and silently leaving it alone hides corruption; this tool reports the position instead. HTML entities are resolved for the full named set plus numeric decimal and hexadecimal references, so both & and & and & decode to the same ampersand. Round-tripping is checked, so you can confirm that decode-then-encode returns your original input byte for byte.
Casos de uso comuns
- Build a query string by hand and encode a search term that contains spaces, ampersands or non-Latin characters.
- Look at a tracking URL that has been encoded twice and work out what the real destination is.
- Escape user-supplied text before pasting it into an HTML template or an email body.
- Decode an OAuth redirect_uri parameter to find out why the authorization server rejects it.
- Turn a URL parameter that contains a nested URL into its encoded form for a callback or webhook configuration.
- Confirm that a value you are about to write into an attribute cannot break out of the quotes.
Última atualização: 2026-10-14 — o corpo do artigo é exibido em inglês; a interface está traduzida.