URL Encoder / Decoder
Encode special characters for URLs or decode percent-encoded URLs back to readable text.
About the URL Encoder / Decoder
URL encoding (also called percent-encoding) converts special characters into a format safe for transmission in URLs. Characters like spaces, ampersands, question marks, and non-ASCII symbols are replaced with a '%' followed by their hex value. Our URL encoder/decoder handles the complete encoding process, making your URLs compatible with all web browsers and servers. Processing is done entirely in your browser.
What Is URL Encoder / Decoder?
A URL can only contain a limited set of unreserved ASCII characters — letters, digits, and the symbols '-', '_', '.', '~'. Any other character, including spaces, non-ASCII letters, emoji, and reserved delimiters such as '/', '?', '&', '=', and '#', must be percent-encoded to avoid being misinterpreted as part of the URL structure. Percent-encoding replaces each such byte with a '%' followed by two hexadecimal digits (for example, a space becomes '%20'). Encoding is essential when placing arbitrary text in query-string parameters, path segments, or form bodies (application/x-www-form-urlencoded). Note that query strings and path segments follow slightly different rules: a space is '%20' in a path but '+' in a form-encoded body. JavaScript's encodeURIComponent handles the most common case and is what this tool uses.
How to Use
- Paste your URL or text into the input field above.
- Click 'Encode URL' to convert special characters to percent-encoded format.
- Click 'Decode URL' to convert a percent-encoded URL back to readable text.
- Copy the encoded or decoded result using the Copy button.
- Use the output directly in links, API calls, or HTML href attributes.
Common Use Cases
- Building query-string parameters that contain spaces, ampersands, or unicode
- Decoding percent-encoded URLs copied from browser address bars or logs
- Preparing redirect URLs embedded inside other URLs (double-encoding)
- Debugging API requests where special characters break parameter parsing
- Sanitizing user input before placing it into an href or src attribute
Examples
https://example.com/search?q=hello world&lang=zh
https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dhello%20world%26lang%3Dzh
encodeURIComponent encodes every reserved character, including ':' and '/'.
Tips & Best Practices
- URL encoding is different from HTML entity encoding — use the appropriate tool for each.
- Query parameters with special characters (like &, =, spaces) must be URL-encoded.
- Decoding is useful for understanding what a complex URL actually contains.
- All modern browsers automatically encode URLs, but manual encoding is needed for API development.
Frequently Asked Questions
What is the difference between encodeURI and encodeURIComponent?
encodeURI keeps characters that are part of a URL's structure (':', '/', '?', '&', '=', '#') intact, so it is used for whole URLs. encodeURIComponent encodes everything except A–Z, a–z, 0–9, '-', '_', '.', '~', making it correct for individual query parameter values. This tool uses encodeURIComponent.
Why is a space sometimes '%20' and sometimes '+'?
'%20' is the standard percent-encoded space and is valid anywhere in a URL. '+' as a space is a convention specific to application/x-www-form-urlencoded form bodies. In a path or query string you should prefer '%20'.
Should I encode a URL twice in some cases?
Yes. When a URL is itself the value of a query parameter, the inner URL's reserved characters must be encoded once for the parameter value. If that result is then placed inside another parameter context, it may need a second pass — this is called double-encoding.
Does URL encoding protect against XSS?
No. URL encoding only makes text safe for URLs. To prevent cross-site scripting you must HTML-escape user input before inserting it into page content — use the HTML Entity Encoder tool for that.
This url encoder / decoder runs entirely in your browser. No data is uploaded to any server. Your privacy is completely protected.
Related Tools
Base64 Encoder / Decoder
Encode text to Base64 or decode Base64 strings back to plain text. Supports UTF-8 and binary data.
HTML Entity Encoder / Decoder
Encode special HTML characters to entities and decode HTML entities back to readable text.
JSON Formatter
Format, validate, and beautify JSON data instantly. Parse and fix malformed JSON with syntax highlighting.
QR Code Generator
Generate QR codes from URLs, text, or any data. Customizable size and color. Free, no sign-up needed.