Loading...

URL Encoding in HTML

URL encoding is the process of converting special characters in URLs into a format that browsers and servers can correctly interpret.

What is URL Encoding?

Some characters like spaces, accents, & or = cannot appear directly in URLs. These must be encoded, for example, a space becomes %20.

Practical Examples

Let's see how a URL looks before and after encoding, especially with accented characters and spaces.

html

https://example.com/search?q=readytools linksy
// encoded: https://example.com/search?q=readytools%20linsky

html

https://example.com/page?name=János
// encoded: https://example.com/page?name=J%C3%A1nos

When to Use It?

You should encode values whenever sending user input or special characters in a URL, such as from a search box or form.

HTML Example

If a URL in an HTML link contains parameters with spaces or special characters, it must be encoded to work correctly.

html

<a href="https://example.com/search?q=hello%20world">Search</a>

How to Encode with JavaScript?

JavaScript's built-in encodeURIComponent() function helps safely encode URL parameters so they work correctly in browsers and on servers.

html

encodeURIComponent("János & Kati") 
// output: J%C3%A1nos%20%26%20Kati

Decoding (URL Decoding)

If you receive already encoded text, you can decode it back to readable format using the decodeURIComponent() function.

html

decodeURIComponent("J%C3%A1nos%20%26%20Kati") 
// output: János & Kati

Track Your Progress 🚀

Learn more easily by tracking your progress completely for free.


Top tools

CodeHubBoardly NEWLinksy NEWChromo NEW

Select Language

Set theme

© 2025 ReadyTools. All rights reserved.