Hongmu Notes

🧷 URL encoding and decoding

The encoding gives two writing methods at the same time, and the decoding restores the %XX content.

Instructions for use

  • Click "Encode" to get both encodeURI and encodeURIComponent results at the same time
  • Click "Decode" to restore %XX content using decodeURIComponent
  • "Content exchange" backfills the results into the input box, and a prompt will be given for illegal percent signs.

encodeURI encoding

encodeURI is suitable for processing "entire links": it only encodes the necessary characters, leaving the structural symbols of the link intact.

📌 The difference with encodeURIComponent

The difference lies in whether the structural symbols are encoded: encodeURI will retain symbols such as : / ? & =, so the result is still a link with a complete structure; encodeURIComponent will also encode these symbols, which is more suitable for putting into a single parameter value.

🧭 Common uses

It is common to assemble query links with Chinese characters or spaces, safely put user input into parameter values, check the encoded string returned by the backend, and troubleshoot problems such as "& in parameters are treated as delimiters." The two encoding results are given side by side, and the impact of structural symbols can be intuitively seen.

🔒 Dealing with location and privacy

Encoding and decoding are completed locally in the browser. Input and results are not uploaded to the server or written to local storage. They are cleared when the page is refreshed. This is standard character escape and does not provide confidentiality capabilities. Please use specialized encryption tools for sensitive data.

All keywords and tutorials 12

❓ FAQ

What will spaces be encoded into?
will be encoded as %20.
How to deal with Chinese
Encode byte-by-byte in UTF-8 into multiple %XX fragments.
Where encodeURI applies
The entire link and path part; please use encodeURIComponent for parameter values.