Online Tools Toolshu.com Log In Sign Up

URL Encoder & Decoder

Tool Introduction

URL Encode & Decode Tool is a free online utility for handling special characters in URLs. Whether you're developing APIs, debugging requests, or working with URLs containing Chinese text or special symbols, this tool helps you encode and decode quickly — no installation required.


What Is URL Encoding?

URLs can only contain a limited set of characters — letters, digits, and a few symbols like -, _, ., ~. All other characters (such as Chinese text, spaces, &, =, or +) must be percent-encoded: converted to %XX hexadecimal format. For example, a space becomes %20, and the Chinese characters "你好" become %E4%BD%A0%E5%A5%BD.


Key Features

  • URL Encode: Converts plain text or special characters into a URL-safe encoded format for safe transmission in web addresses.
  • URL Decode: Restores percent-encoded URL strings back to human-readable text, making it easy to read URL parameters.
  • Two Encoding Modes: Switch between encodeURIComponent (for URL parts) and encodeURI (for full URLs) to suit different use cases.
  • Clear Input: One-click to clear the input box for a clean start.

Two Encoding Modes Explained

This tool offers two encoding methods based on JavaScript's built-in functions:

  • encodeURIComponent: Encodes a URI component (e.g., a query parameter value). It escapes all characters except letters, digits, and - _ . ! ~ * ' ( ). Best for encoding individual parameter values.
  • encodeURI: Encodes a complete URI while preserving structural characters like : / ? # & = @. Best when you want to encode an entire URL without breaking its structure.

Common Use Cases

  • Developers encoding Chinese or special-character query parameters before sending API requests;
  • Marketers fixing broken promotional links caused by unencoded special characters;
  • Students learning how URL percent-encoding works with different character sets;
  • Testers analyzing and decoding URL parameters found in logs or browser address bars.

How to Use

  1. Paste or type your text or URL into the input field;
  2. Choose between "Encode URI Component" or "Encode Full URI" mode;
  3. Click URL Encode to encode, or URL Decode to decode;
  4. The result appears instantly and can be copied directly.

FAQ

What's the difference between URL encoding and Base64 encoding?

URL encoding (percent-encoding) replaces special characters with %XX sequences and is designed for safe transmission in URLs. Base64 converts any binary data into an ASCII string, typically used for encoding files or images in text form. They serve different purposes and are not interchangeable.


Why does a single Chinese character produce a long %XX string?

In UTF-8 encoding, a Chinese character typically takes 3 bytes. Each byte is represented as one %XX group, so a single Chinese character produces 3 groups — 9 characters total. This is standard and expected behavior.


When should I use encodeURIComponent vs. encodeURI?

Use encodeURIComponent when encoding a single parameter value — it will also escape structural characters like &, =, and ?. Use encodeURI when encoding an entire URL that must keep its structure intact, as it preserves those structural characters.


Why is a space sometimes %20 and sometimes +?

Both represent a space, but in different contexts. %20 is the standard percent-encoding for a space character. The + sign represents a space in the older application/x-www-form-urlencoded format used by HTML forms. This tool uses the standard %20 encoding.

发现周边 发现周边
Comment area

Loading...