URL Encoder & Decoder
URL encoding converts characters into a format safe for transmission in URLs. Special characters like spaces, ampersands, and question marks are converted to percent-encoded values. This tool supports both encodeURIComponent and encodeURI methods.
encodeURIComponent
Encodes special characters including: ; , / ? : @ & = + $ #
Best for query parameters and path segments.
encodeURI
Preserves URL structure characters: ; , / ? : @ & = + $ #
Best for encoding complete URLs.
How to Encode/Decode URLs
- 1
Select Mode & Type
Choose Encode or Decode mode, then select encodeURIComponent (for query params) or encodeURI (for full URLs).
- 2
Enter Your Text
Paste your text or URL into the input field. For encoding, enter plain text. For decoding, enter the percent-encoded string.
- 3
Get Your Result
Click the action button and copy your encoded/decoded result from the output field.
Frequently Asked Questions
What is URL encoding?
URL encoding (also called percent-encoding) converts characters into a format that can be transmitted over the Internet. Special characters are replaced with a '%' followed by their hexadecimal value. For example, a space becomes '%20'.
What's the difference between encodeURI and encodeURIComponent?
encodeURI is used for encoding complete URLs and preserves URL-special characters like /, ?, &, =. encodeURIComponent encodes everything except letters, digits, and a few special characters, making it ideal for encoding query parameter values.
When should I URL encode?
You should URL encode when: passing data in URL query strings, including special characters in URLs, sending form data, or working with any text that will be part of a URL. This ensures the URL is valid and properly interpreted.
Why do I see %20 instead of spaces in URLs?
Spaces are not allowed in URLs according to RFC 3986. When a space needs to be included in a URL, it must be encoded as %20 (the hexadecimal representation of the space character). Some systems also use + for spaces in query strings.
When to Use encodeURI vs encodeURIComponent
encodeURIComponent: Use when encoding a single value that will go in a query parameter or path segment. Encodes /, ?, &, =, and other reserved chars. Example: ?q= + encodeURIComponent(userInput).
encodeURI: Use when encoding an entire URL but preserving structure. Leaves / and ? unencoded so the URL remains parseable. Example: encodeURI('https://example.com/path?foo=bar').
CLI and Code Examples
encodeURIComponent('hello world!') // "hello%20world%21"
from urllib.parse import quote; quote('hello world!')
Edge Cases
- Double encoding: Encoding already-encoded text produces
%2520instead of%20. Decode once before re-encoding. - Spaces: Encoded as
%20. Inapplication/x-www-form-urlencoded, spaces are often+; both decode to space. - Unicode: Multi-byte UTF-8 characters become multiple
%XXsequences. Ensure your system treats the result as UTF-8.
Security Notes
Improper URL encoding can lead to injection (e.g. open redirects, parameter pollution). Always encode user-controlled values before placing them in URLs. Validate and sanitize decoded input on the server. See RFC 3986 for the full specification.