What is URL Encoding?
URL encoding (also called percent-encoding) converts characters that are not allowed in a URL into a safe representation. Each unsafe character is replaced by a percent sign followed by two hexadecimal digits representing the character's ASCII code. For example, a space becomes %20 and an ampersand becomes %26.
Why is URL Encoding Necessary?
URLs can only contain a limited set of ASCII characters. Characters outside this set — such as spaces, accented letters, and symbols like &, =, and ? — have special meanings or are simply not allowed. Without encoding, these characters can break links, corrupt query strings, or prevent servers from parsing the request correctly.
Encode vs. Decode
- Encode — converts plain text into a percent-encoded URL-safe string. Use this when building query parameters or passing user input as part of a URL.
- Decode — converts a percent-encoded string back to readable text. Use this when inspecting a URL you received from a server or a log file.
Frequently Asked Questions
What is the difference between encodeURI and encodeURIComponent?
encodeURI encodes a complete URL and leaves characters like /, ?, and & intact. encodeURIComponent encodes a URL component (such as a query value) and also encodes those characters. This tool uses encodeURIComponent to safely encode individual values.
Does this tool send my data to a server?
No. All encoding and decoding runs in your browser via the built-in encodeURIComponent and decodeURIComponent functions. Nothing is transmitted.
Why does decoding fail?
Decoding fails when the input contains a malformed percent sequence — for example, %GG (non-hex digits) or a lone % not followed by two hex digits. Ensure the input is a valid percent-encoded string before decoding.