Spaces, special characters, and non-ASCII text in URLs must be percent-encoded. A developer-friendly guide to why URL encoding exists, when you need it, and common mistakes to avoid.
URLs can only safely contain a specific set of characters. Spaces, special symbols, non-ASCII characters, and reserved characters in URLs all need to be encoded before they can be transmitted reliably. If you have ever seen %20 in a URL, you have seen percent-encoding in action. Here is what it does, when you need it, and how to encode and decode URLs instantly.
URL encoding, formally called percent-encoding, converts characters that are not allowed or have special meaning in URLs into a safe representation. Each unsafe character is replaced by a % followed by two hexadecimal digits representing the character's ASCII or UTF-8 byte value.
Examples:
%20 (or + in form data)& → %26= → %3D/ (in a parameter value) → %2F@ → %40%C3%A9 (UTF-8 bytes)URLs were originally designed for ASCII text in a strict format:scheme://host/path?query#fragment. Specific characters in this structure have reserved meanings:
/ separates path segments? begins the query string& separates query parameters= assigns query parameter values# begins a fragment identifierIf your query parameter value contains any of these characters (e.g. a URL containing another URL, or a search query containing “&”), the URL parser will misinterpret them. Encoding the special characters prevents this.
mailto: links in HTML that include a pre-filled subject or body require URL encoding.| Encoding type | Used in | Example |
|---|---|---|
| URL encoding (percent-encoding) | URLs, query strings | Space → %20 |
| HTML encoding (entity encoding) | HTML content and attributes | < → <, Space → |
| Base64 encoding | Binary data, email, JWTs | Binary bytes → printable ASCII string |
All three serve different purposes and should not be confused. For HTML-specific encoding, use the HTML Encoder / Decoder tool instead.
% itself gets encoded to %25, producing%2520 instead of %20. Always decode before re-encoding.://, /, and ?) breaks the URL structure. Only encode the values within the URL.URL encoding is a fundamental web concept that every developer and anyone working with web APIs needs to understand. The ToolsGravity URL Encoder / Decoder handles both directions instantly — encode for safe URL construction, decode to read obfuscated URL parameters. Remember the key distinction: encode components (parameter values), not entire URLs.