URL Encoder / Decoder
Paste a URL or text to encode it for safe URL transmission, or paste an encoded URL to decode it back.
Reviewed by the ToolNestr Editorial Team — July 2026
How URL encoding works
URL encoding, also known as percent-encoding, replaces unsafe or reserved characters in a URL with a percent sign (%) followed by two hexadecimal digits representing the character's ASCII code. This ensures that characters with special meaning in URLs (like ?, &, #, and space) are transmitted safely without breaking the URL structure.
The tool uses JavaScript's encodeURIComponent() for encoding, which is the correct function for encoding query parameter values as it encodes everything including characters like :, /, and ?. For decoding, it handles both percent-encoded sequences and plus signs (which represent spaces in form-encoded application/x-www-form-urlencoded data).
Worked example
Characters that need URL encoding
How frequently each character requires percent-encoding in real-world URLs.
Aisha Kapoor
Web developer who encodes user-generated content before appending it to query strings and decodes incoming URL parameters for display on pages.
David Okonkwo
API integrator who encodes payloads and query parameters when hitting third-party REST endpoints, ensuring special characters do not break the request.
Sarah Mitchell
Marketer who builds UTM-tracked campaign URLs and needs to encode spaces and special characters so analytics tools parse them correctly.
Carlos Mendez
QA tester who decodes obfuscated URLs to verify redirect logic and checks that encoded parameters survive round-trip through the application.
| Character | Encoded | Why it needs encoding |
|---|---|---|
| space | %20 | Not allowed in URLs |
| ! | %21 | Reserved character |
| # | %23 | Fragment identifier start |
| $ | %24 | Reserved character |
| % | %25 | Percent-encoding indicator |
| & | %26 | Query separator |
| + | %2B | Represents space in form data |
| , | %2C | Reserved character |
| / | %2F | Path separator |
| : | %3A | Scheme/port separator |
| ; | %3B | Reserved character |
| = | %3D | Key-value separator |
| ? | %3F | Query string start |
| @ | %40 | User-info separator |
How to use URL Encoder / Decoder
Paste your text
Type or paste the text, URL, or query parameter you want to encode or decode into the input area.
Choose direction
Click Encode to percent-encode special characters, or Decode to convert percent-encoded sequences back to their original form.
Copy the result
Use the Copy button to grab the output. The analysis section shows exactly which characters were encoded or decoded.
Tips for URL encoding
Always encode query parameter values
When building URLs dynamically, always use encodeURIComponent() on parameter values to prevent &, =, and # from breaking the URL structure. A single unencoded & can split your query string.
Do not encode the entire URL
Use encodeURI() for the full URL (preserves ://?#) and encodeURIComponent() only for individual parameter values. Encoding the full URL with encodeURIComponent() will break the scheme and path separators.
Avoid double encoding
If you encode a string that is already percent-encoded, the % characters become %25, creating double encoding. Most servers will not decode %2520 back to a space. Check before encoding.
What is URL encoding?
URL encoding, also known as percent encoding, is a mechanism for translating characters that have special meaning in URLs into a safe, universally accepted format. Each character is replaced by a percent sign followed by two hexadecimal digits representing its byte value. For example, the space character (ASCII 32) becomes %20. This ensures that URLs remain valid across the internet regardless of the characters they contain.
Why it is needed
URLs have a restricted character set defined by RFC 3986. Characters like &, ?, #, and space have reserved purposes within the URL syntax. Without encoding, a user searching for "cats & dogs" would produce a URL where & splits the query string prematurely. URL encoding prevents these ambiguities by converting problematic characters into a safe representation that servers and browsers can reliably parse.
encodeURI vs encodeURIComponent
JavaScript provides two functions for URL encoding. encodeURI() is designed to encode a complete URI while leaving characters like ://?#/ intact so the URL remains functional. encodeURIComponent() is more aggressive and encodes those characters as well, making it the correct choice for encoding individual query parameter values. Using encodeURI() on a parameter value will not encode the & or = characters, potentially breaking the URL.
Common pitfalls
One common mistake is forgetting to encode user input before inserting it into a URL, leading to broken links or security vulnerabilities. Another is double encoding by encoding an already-encoded string. Developers also confuse URL encoding with HTML encoding — they serve different purposes. Finally, some characters like + have special meaning (space alternative in query strings), so encoding them appropriately is important for correct behavior.
Frequently asked questions
What is URL encoding?
URL encoding (percent encoding) replaces special characters in a URL with a percent sign (%) followed by two hexadecimal digits representing the character's ASCII code. For example, a space becomes %20.
Why are spaces encoded as %20?
Spaces are not allowed in URLs. The ASCII code for space is 32 decimal, which is 20 in hexadecimal, so it is encoded as %20. Modern browsers may display %20 as a space, but the actual URL contains %20.
What is the difference between encodeURI() and encodeURIComponent()?
encodeURI() encodes a full URI while preserving characters that are part of the URI syntax (:, /, ?, #). encodeURIComponent() encodes everything including those characters, making it suitable for encoding query parameter values.
When should I use encodeURIComponent()?
Always use encodeURIComponent() when encoding the value of a query parameter. If a user types "hello world & more" into a search box, encodeURIComponent() will safely encode the spaces and the & character.
What characters need encoding in a URL?
Characters like space, &, ?, #, %, =, +, @, $, and non-ASCII characters all need encoding. Only letters, digits, and the characters - _ . ~ are always safe in URLs.
Can I put a URL with Chinese or Arabic characters in a browser?
Modern browsers automatically encode non-ASCII characters in the address bar. However, the underlying protocol requires them to be percent-encoded. This tool helps you see what the browser is doing behind the scenes.
Is URL encoding the same as HTML encoding?
No. URL encoding uses % followed by hex digits (e.g., %20 for space). HTML encoding uses entity names or numbers (e.g., for non-breaking space). They serve different purposes in different contexts.
Why does my URL break when I include & in a query parameter?
The & character is used to separate query parameters. If your parameter value contains &, it must be encoded as %26 so the URL parser does not treat it as a parameter separator.
What happens if I double-encode a URL?
If you encode an already-encoded URL, the % characters themselves get encoded to %25. For example, %20 becomes %2520. Most servers will not decode this correctly, so avoid encoding more than once.
How can I tell if a string is already URL-encoded?
Look for % followed by two hexadecimal digits. However, not every % sequence guarantees valid encoding. The safest approach is to decode first, then re-encode when needed.