What is the URL Encode / Decode?
The URL Encode / Decode tool converts reserved, non-ASCII, and unsafe characters into their percent-encoded equivalents (e.g. spaces → %20 or +) for web browser navigation and REST query strings, and translates percent-encoded strings back into readable text. It supports both full URL encoding (encodeURI) and component parameter encoding (encodeURIComponent).
Uniform Resource Identifiers (URIs) only permit a restricted subset of US-ASCII characters. Passing spaces, ampersands, question marks, hashes, or non-Latin characters directly inside URL query parameters causes server parsing ambiguities, broken links, and security vulnerabilities.
How to Use the URL Encode / Decode
- Select Mode: Choose Encode to make text URL-safe, or Decode to convert percent codes back to text.
- Choose Scope: Select Component Mode (for query parameter values) or Full URL Mode (preserving protocol and domain slashes).
- Input String: Type or paste your URL or query parameter.
- Copy Output: Copy the safe percent-encoded string for use in your API call or link.
Formula & How It Works
Percent-encoding maps unsafe characters into a '%' followed by their two-digit hexadecimal byte value:
Standard Mapping:
Space (' ') → %20 (or '+' in query strings)
Ampersand ('&') → %26
Question Mark ('?') → %3F
Slash ('/') → %2F
Hash ('#') → %23
Equals ('=') → %3D
JavaScript Functions:
encodeURIComponent(str): Encodes all reserved punctuation characters.
encodeURI(str): Preserves protocol slashes and domain colons.
decodeURIComponent(str): Decodes all percent sequences.Worked Example: Query string value: name=John & Doe?. Encoded via encodeURIComponent: name%3DJohn%20%26%20Doe%3F.
Practical Worked Examples
| Original Character / String | Percent-Encoded | Reason for Encoding |
|---|---|---|
| Space (" ") | %20 | Spaces are illegal in raw URLs |
| "&" (Ampersand) | %26 | Prevents splitting into unintended query params |
| "https://example.com/search?q=cat & dog" | https://example.com/search?q=cat%20%26%20dog | Maintains URL structural integrity |
Common Everyday & Professional Use Cases
Constructing webhook redirect callback URLs, passing parameters in OAuth authorization requests, formatting social share buttons, and debugging server access logs.