URL Encoder / Decoder β Percent-Encode and Decode URLs
Encode or decode URLs and query strings instantly. Supports encodeURIComponent, encodeURI, and query string formats. Breaks down URLs into protocol, host, path, and parameters.
What Is URL Encoding?
URL encoding (also called percent encoding) converts characters that are not allowed or have special meaning in a URL into a safe representation. Each unsafe byte is replaced with a percent sign followed by two hexadecimal digits β for example, a space becomes %20, and an ampersand becomes %26. The encoding is defined in RFC 3986.
URLs can only contain a limited set of characters from the ASCII character set. Characters outside this set β including spaces, international characters, and most punctuation β must be encoded before they appear in a URL. Forgetting to encode special characters in query parameters is one of the most common causes of broken API requests and 400 errors.
encodeURIComponent vs encodeURI β Which to Use?
JavaScript provides two built-in functions for URL encoding, and choosing the wrong one is a frequent source of bugs:
- encodeURIComponent encodes every character except
AβZ aβz 0β9 - _ . ! ~ * ' ( ). Use this for individual query parameter values β it encodes?,&,=, and/, preventing them from being interpreted as URL structure. - encodeURI encodes everything that
encodeURIComponentencodes, but preserves URI structural characters:: / ? # [ ] @ ! $ & ' ( ) * + , ; =. Use this for encoding a complete URL while keeping its structure intact. - Query string encoding (used by HTML forms) is like
encodeURIComponentbut converts spaces to+instead of%20. Many servers treat the two as equivalent, but%20is technically correct per RFC 3986.
How to Encode or Decode a URL
- Encode tab: Paste the text or URL component you want to encode. Choose the encoding mode (encodeURIComponent for query values, encodeURI for full URLs). The encoded output appears instantly with encoded characters highlighted in amber.
- Decode tab: Paste any percent-encoded URL or string. The tool decodes it and, if the input is a valid URL, shows a breakdown of each component: protocol, host, path, query parameters, and hash fragment.
- Load sample: Click the βLoad sampleβ button in the Decode tab to see a realistic example URL with multiple query parameters.
FAQ
Frequently Asked Questions
Related Tools
- Format and validate JSON API responses with our JSON Formatter & Validator.
- Encode binary data or files as Base64 with our Base64 Encoder / Decoder.
- Decode Unix timestamps found in URL parameters with our Unix Timestamp Converter.