DevOps & Development Experts
From CI/CD pipelines to custom applications, our team builds secure solutions that scale.
What Is URL Encoding
URL encoding (also called percent-encoding) converts characters into a format that can be safely transmitted in a URL. URLs can only contain a limited set of ASCII characters: letters, digits, and a few special characters like hyphens and underscores. Any other character—spaces, non-ASCII letters, special symbols—must be encoded as a percent sign followed by two hexadecimal digits representing the character's byte value.
This encoding scheme is defined in RFC 3986 and is fundamental to how the web works. Every time you search for something with spaces, submit a form, or share a URL containing special characters, URL encoding is happening behind the scenes. Understanding it is essential for web developers, API designers, security professionals, and anyone working with HTTP requests.
How URL Encoding Works
URL encoding replaces unsafe characters with a percent sign (%) followed by their hexadecimal ASCII value. Multi-byte characters (like Unicode) are first encoded in UTF-8, then each byte is percent-encoded individually.
| Character | Encoded | Reason |
|---|---|---|
| Space | %20 or + | Delimiter in URLs |
| & | %26 | Query parameter separator |
| = | %3D | Key-value pair separator |
| ? | %3F | Query string start marker |
| # | %23 | Fragment identifier |
| / | %2F | Path separator |
| @ | %40 | Userinfo separator |
| + | %2B | Interpreted as space in forms |
| % | %25 | Encoding escape character itself |
Reserved characters have special meaning in URLs (/, ?, &, =, #, @). They must be encoded when used as data rather than as delimiters. Unreserved characters (A-Z, a-z, 0-9, -, _, ., ~) never need encoding.
For example, searching for "C++ programming" in a query string becomes: q=C%2B%2B+programming or q=C%2B%2B%20programming.
Common Use Cases
- API development: Encode query parameters containing special characters, spaces, or Unicode text
- Form submissions: HTML forms encode field values before sending them in POST or GET requests
- URL construction: Build URLs programmatically with dynamic segments that may contain reserved characters
- Security testing: Test for URL-based injection vulnerabilities by encoding payloads
- Deep linking: Create shareable URLs with parameters that include special characters or non-English text
Best Practices
- Encode data, not structure — Only encode the values within query parameters, not the delimiters (?, &, =) themselves
- Use language-native functions — JavaScript's
encodeURIComponent(), Python'surllib.parse.quote(), and similar built-in functions handle encoding correctly - Don't double-encode — Encoding an already-encoded string produces invalid URLs (e.g., %20 becomes %2520)
- Always use UTF-8 — UTF-8 is the universally accepted encoding for URLs per RFC 3986; avoid legacy encodings like Latin-1
- Decode for display, encode for transport — Show human-readable URLs in the browser address bar but always encode values in HTTP requests
References & Citations
- Wikipedia. (2024). Percent-encoding (URL Encoding). Retrieved from https://en.wikipedia.org/wiki/Percent-encoding (accessed January 2025)
- T. Berners-Lee et al.. (2005). RFC 3986: Uniform Resource Identifier (URI): Generic Syntax. IETF. Retrieved from https://datatracker.ietf.org/doc/html/rfc3986 (accessed January 2025)
Note: These citations are provided for informational and educational purposes. Always verify information with the original sources and consult with qualified professionals for specific advice related to your situation.
Key Security Terms
Understand the essential concepts behind this tool
Frequently Asked Questions
Common questions about the URL Encode/Decode with Query Parser
URL encoding (percent-encoding) converts special characters to safe format for URLs using %XX notation where XX is hexadecimal ASCII code. Example: space becomes %20, @ becomes %40. Necessary because: URLs only support ASCII characters, special characters have meaning in URLs (? starts query, & separates parameters, # is fragment), spaces not allowed, non-ASCII characters (中文, émoji) need encoding. Without encoding: "https://site.com?search=hello world" breaks (space invalid). Encoded: "?search=hello%20world". Used in: query parameters, path segments, form data. Not needed in: domain names (use punycode), within HTML (different escaping). This tool encodes/decodes instantly.