URL Encode/Decode
Supports Chinese and special character percent encoding, provides both encodeURI and encodeURIComponent methods
About URL Encoding
URL encoding (also known as percent encoding) is a mechanism for encoding information in Uniform Resource Identifiers (URIs). It represents certain characters by replacing them with triplets consisting of a percent sign '%' followed by two hexadecimal digits, ensuring the safety and compatibility of URLs during transmission.
URL encoding is necessary when a URL contains characters that have special meanings in the syntax, or characters that are not allowed in URLs. Through encoding, URLs can be reliably transmitted between browsers, servers, and various network components.
encodeURI (does not encode special symbols)
Suitable for encoding complete URLs. Does not encode the following characters: : / ? # [ ] @ ! $ & ' ( ) * + , ; =.
Use case: Encoding complete URL addresses, for example, encoding an entire URL with query parameters.
encodeURIComponent (encodes special symbols)
Encodes almost all non-alphanumeric characters, including: : / ? # [ ] @ ! $ & ' ( ) * + , ; =.
Use case: Encoding URL parameter values or individual fields in query strings.
Important Notes: Different parts of a URL (protocol, host, path, query, fragment) have different encoding rules. The same string may require different encoding methods in different positions. This tool provides both encodeURI and encodeURIComponent methods for you to choose the appropriate one based on your actual scenario.
Common Characters and Their Encodings
| Character | URL Encoding | Description |
|---|---|---|
| Space | %20 | Space character |
| ! | %21 | Exclamation mark |
| " | %22 | Quotation mark |
| # | %23 | Hash/fragment identifier |
| % | %25 | Percent character |
| & | %26 | Ampersand/query separator |
| + | %2B | Plus sign |
| = | %3D | Equals sign/query value separator |
| ? | %3F | Question mark/query indicator |
Common Use Cases
- Encoding query parameters in web forms
- Handling special characters in API requests
- Processing filenames with special characters in URLs
- Encoding email addresses and other data in URLs
- Debugging web applications and API calls
Examples
Example 1: Query Parameters
Original: Hello World!
Encoded: Hello%20World%21
Example 2: Email Address
Original: user@example.com
Encoded: user%40example.com
Example 3: Complex Query
Original: search=JavaScript & Node.js
Encoded: search%3DJavaScript%20%26%20Node.js