How to URL Encode a String
- Select the Encode → tab.
- Paste or type the text you want to encode in the left box.
- The URL-encoded output appears instantly in the right box.
- Click Copy to copy the result to your clipboard.
How to URL Decode a String
- Select the ← Decode tab.
- Paste your percent-encoded string (e.g.
hello%20world%21) in the left box. - The decoded, human-readable text appears on the right.
- If the input contains invalid escape sequences, an error message explains the problem.
What Is URL Encoding?
URL encoding — formally called percent encoding and defined in RFC 3986 — converts characters that cannot safely appear in a URL into an ASCII-compatible representation. Each character that needs encoding becomes a percent sign % followed by two hexadecimal digits: the UTF-8 byte value of the character.
For example, a space character (UTF-8 byte 0x20) becomes %20. An equals sign (0x3D) becomes %3D. An ampersand (0x26) becomes %26.
| Character | Encoded | Why it matters |
|---|---|---|
| Space | %20 | Spaces are illegal in URLs |
| = | %3D | Separates query parameter name from value |
| & | %26 | Separates multiple query parameters |
| + | %2B | Ambiguous — sometimes decoded as a space |
| / | %2F | Path separator — must be encoded in values |
| ? | %3F | Starts the query string — must be encoded in values |
| # | %23 | Fragment identifier — must be encoded in values |
| @ | %40 | Used in userinfo and email addresses |
| : | %3A | Port and scheme separator |
| % | %25 | Escape character itself — must be encoded literally |
encodeURIComponent vs encodeURI
JavaScript has two built-in functions for URL encoding, and choosing the wrong one is a common source of bugs:
- encodeURIComponent — encodes everything except letters, digits, and
- _ . ! ~ * ' ( ). Use this for individual query parameter values. This is what this tool uses. - encodeURI — leaves URL structural characters intact (
: / ? # [ ] @and others) so a complete URL is not broken. Use this only when you want to encode an entire URL that is already well-formed.
Rule of thumb: if you are encoding a value to put inside a query string (like a search term or a redirect URL), always use encodeURIComponent. If you are encoding an entire URL for use as an attribute value in HTML, use encodeURI first and then encode the result only if needed.
Frequently Asked Questions
What is URL encoding?
URL encoding replaces unsafe characters in a URL with a percent sign (%) followed by two hexadecimal digits. For example, a space becomes %20. This makes it possible to include any character in a URL without breaking the URL structure.
Why does %20 appear in my URLs?
%20 is the URL-encoded form of a space character. It appears when a URL contains a space that was encoded by a browser, form handler, or API. Paste the URL into the Decode tab to read it in plain text.
What is the difference between %20 and + for spaces?
Both represent a space, but in different contexts. %20 is the RFC 3986 standard and is safe anywhere in a URL. The + sign for spaces comes from the older application/x-www-form-urlencoded format used by HTML forms. Stick with %20 unless you are specifically working with HTML form data.
Is my data sent to a server?
No. Encoding and decoding run entirely in your browser using JavaScript's built-in encodeURIComponent() and decodeURIComponent() functions. No network requests are made — you can verify this by opening DevTools and checking the Network tab.
Why do I get an error when decoding?
A decode error means the input contains an invalid percent-escape sequence — for example, a lone % not followed by two hex digits (like %GG or a truncated %2). Fix the broken sequence or re-copy the encoded string from its source.