URL Encode/Decode

Encode text for URLs or decode URL-encoded strings

Examples

URL Encoding Reference

Reserved Characters

Space%20
!%21
"%22
#%23
$%24
%%25

More Characters

&%26
'%27
(%28
)%29
*%2A
+%2B

Common Usage

  • URL query parameters
  • Form data submission
  • HTTP headers
  • API requests
  • Email addresses in URLs

Complete URL Encode/Decode Guide

URL encoding (also known as percent-encoding) is the process of converting special characters in URLs to a safe format, ensuring URLs can be correctly transmitted over the internet. Since URLs can only use specific characters from the ASCII character set, any characters outside this range (like spaces, Chinese characters, special symbols) need to be encoded. This tool provides fast, accurate URL encoding and decoding capabilities, supporting all Unicode characters, making it an essential tool for web development, API debugging, and data transmission.

1
如何使用 / How to Use

Step 1: Select Operation Mode

Click the "Encode" or "Decode" button at the top to select the operation mode. Encode mode converts text to URL-safe format, decode mode restores URL-encoded strings to original text.

Step 2: Input Text or URL

Paste or type the content to process in the left input box. In encode mode, enter text or URLs containing special characters; in decode mode, enter URL-encoded strings with %XX format. Supports any length and Unicode characters.

Step 3: Execute Conversion

Click the "Encode" or "Decode" button to execute the conversion. The conversion result will immediately appear in the right output box. The tool automatically handles UTF-8 encoding, ensuring correct conversion of multi-byte characters like Chinese.

Step 4: View Conversion Statistics

After successful conversion, the length and byte size of the result are displayed below the output box. Encode mode also shows size change percentage, helping understand the impact of encoding on URL length.

Step 5: Learn with Examples

Click any example in the examples area to quickly load preset text. Examples include URLs with query parameters, text with special characters, email addresses, and other common scenarios.

Step 6: Quick Switch for Verification

Click the swap icon to quickly switch between encode/decode modes and automatically move the output result to the input box. This is very useful for verifying encoding result correctness.

2
实际应用场景 / Use Cases

1URL Query Parameters

When passing query parameters containing special characters in URLs, URL encoding is required. For example, search keyword "hello world" needs to be encoded as "hello%20world". Chinese parameters like "你好" are encoded as "%E4%BD%A0%E5%A5%BD". This ensures parameters are correctly transmitted in HTTP requests, avoiding misinterpretation as other parts of the URL.

2Form Data Submission

When HTML forms submit data using application/x-www-form-urlencoded format, all field values are URL-encoded. This includes user-entered text, selected options, etc. Understanding URL encoding is important for debugging form submission issues and building AJAX requests.

3API Request Construction

When calling RESTful APIs, special characters in URL path parameters and query parameters need to be encoded. For example, keyword parameters in search APIs, special symbols in filter conditions, etc. Correct URL encoding ensures APIs can properly parse request parameters, avoiding 400 errors or parameter loss.

4Link Sharing

When sharing links containing Chinese or special characters, URL encoding ensures links display and redirect correctly across different platforms (social media, instant messaging, email). Unencoded links may be truncated or unrecognized on some platforms.

5Debugging HTTP Requests

When viewing HTTP requests in browser developer tools or network capture tools, URLs are typically displayed in encoded form. Using a decode tool allows quick viewing of original parameter values, helping understand request content and troubleshoot issues.

6Email Address Handling

When including email addresses in mailto: links or URL parameters, the @ symbol needs to be encoded as %40. This ensures email addresses are not misinterpreted as other parts of the URL. For example, user@example.com is encoded as user%40example.com.

使用技巧与最佳实践 / Tips & Best Practices

Understand Reserved Characters

Characters with special meaning in URLs (like ?, &, =, #, /) are called reserved characters. When these characters need to be used as data content rather than part of URL structure, they must be encoded. For example, & in query parameter values must be encoded as %26, otherwise it will be mistaken for a parameter separator.

Two Encodings for Space

Space can be encoded as %20 or +. In query strings, both + and %20 represent space, but in URL paths only %20 can be used. For consistency, it is recommended to uniformly use %20. This tool uses standard %20 encoding.

Avoid Double Encoding

Already encoded URLs should not be encoded again, otherwise double encoding issues will occur. For example, %20 encoded again becomes %2520. When decoding, also be careful to decode only once. If unsure whether a URL is encoded, try decoding first; if it fails, it means it is not encoded.

UTF-8 Encoding

URL encoding uses UTF-8 character encoding. Multi-byte characters like Chinese are converted to multiple %XX sequences. For example, "你" (UTF-8: E4 BD A0) is encoded as %E4%BD%A0. This tool automatically handles UTF-8 encoding, ensuring all Unicode characters are correctly converted.

Verify Encoding Results

After encoding, it is recommended to use the decode function to verify if the result is correct. Click the swap button to quickly switch to decode mode and check if the decoded text matches the original input. This helps identify encoding issues.

常见问题 / Frequently Asked Questions

技术说明 / Technical Details

This tool uses JavaScript's native encodeURIComponent() and decodeURIComponent() functions to implement URL encoding and decoding. These functions follow RFC 3986 standard, being the most reliable URL encoding method. **Encoding Process**: 1. Convert input text to UTF-8 byte sequence 2. For each byte, if it is a safe character (A-Z, a-z, 0-9, -, _, ., ~), keep it unchanged 3. Other characters are converted to %XX format, where XX is the hexadecimal value of the byte 4. Multi-byte characters (like Chinese) produce multiple %XX sequences **Decoding Process**: 1. Identify %XX patterns 2. Convert hexadecimal values back to bytes 3. Decode byte sequence as UTF-8 to Unicode characters 4. Handle incorrect encoding sequences, providing friendly error prompts **Differences from Other Encoding Methods**: - encodeURI() does not encode URL structure characters (: / ? # etc.), suitable for encoding complete URLs - encodeURIComponent() encodes all special characters, suitable for encoding URL parameters - This tool uses encodeURIComponent(), ensuring maximum compatibility Tech stack: React + TypeScript + native Web API, ensuring high performance and standard compatibility. All operations are completed on the client side, protecting user privacy.

🔒 隐私保护承诺 / Privacy Protection

所有处理都在您的浏览器本地完成,数据不会上传到任何服务器。您的隐私和数据安全是我们的首要任务。
All processing is done locally in your browser. No data is uploaded to any server. Your privacy and data security are our top priorities.