URL Encode
Highlight is a percentage bytes coded.
Free online URL encoder/decoder. encodeURIComponent/encodeURI/RFC 3986 modes, highlighted output, batch processing, Query Only mode. Zero upload.
Related
What is URL Encoding?
URL encoding (Percent-encoding) converts unsafe URL characters to %XX format. URLs only allow a small set of ASCII characters (letters, digits, -_.~); all other characters (Chinese, spaces, special symbols) must be encoded. Space becomes %20, Chinese character 中 becomes %E4%B8%AD.
**encodeURIComponent vs encodeURI**: the two most common encoding functions. encodeURIComponent is more aggressive, encoding &, =, ? etc., suitable for individual parameter values. encodeURI preserves URL structure (scheme://, path, /, ?, #) for complete URLs.
**RFC 3986** treats tilde ~ as an unreserved character (not encoded), reducing unnecessary escapes compared to older standards.
**Query Only mode** encodes only parameter values after =, preserving keys, =, and & symbols.
**Encoding highlight** marks %XX-encoded characters in amber. All processing happens locally in your browser with zero data upload.
Use Cases
- API debugging: compare encodeURIComponent vs encodeURI outputs to debug signature mismatches
- Log decoding: batch-decode URL-encoded log entries back to readable text
- URL building: Query Only mode preserves keys while encoding values
- Frontend dev: encoding highlight helps understand which characters get escaped
- Data migration: batch process URL-encoded data from legacy systems
How to Use
- Paste URL or text to encode/decode
- Select direction (Encode/Decode) and mode (Component/URI/full/RFC 3986)
- Enable batch mode for multi-line, or Query Only for parameter values only
- Copy the highlighted result for API requests or URL building
Features
- 四种编码模式:encodeURIComponent / encodeURI / full / RFC 3986 一键切换,实时对比不同规则输出差异
- 编码高亮:实时高亮显示被转义的 %XX 字符,琥珀色标记让编码结果一目了然
- 批量模式:支持多行批量编码解码,每行独立处理,适合处理日志或批量数据
- Query Only 模式:只编码 URL 参数值部分(等号后内容),保留键名、符号和路径结构不变
- 实时防抖:300ms 自动编码解码,无需点击按钮,输入即出结果
- 字符统计:实时显示输入字符数,方便核对 API 参数长度限制
Code Examples
URL Encoding/Decoding in JavaScript
// encodeURIComponent: encodes individual param values (most common)
const param = encodeURIComponent('Zhang San&Li Si');
console.log(param);
// encodeURI: encodes full URL (preserves :/?#&= structural chars)
const url = encodeURI('https://example.com/search?q=hello world');
console.log(url);
// Decode
const decoded = decodeURIComponent(param);
console.log(decoded);
// RFC 3986 compliant (~ not encoded)
function rfc3986Encode(str) {
return encodeURIComponent(str).replace(/[!'()*]/g,
c => '%' + c.charCodeAt(0).toString(16).toUpperCase());
}
// Modern: URLSearchParams (auto-handles encoding)
const params = new URLSearchParams({name:'Zhang San',city:'Beijing'});
console.log(params.toString());URL Encoding/Decoding in Python
from urllib.parse import quote, unquote, urlencode, quote_plus
# quote: similar to encodeURIComponent
encoded = quote('Zhang San&Li Si')
print(encoded)
# RFC 3986 is default (~ not encoded)
print(quote('hello~world')) # hello~world
# quote_plus: spaces become + (form format)
print(quote_plus('hello world')) # hello+world
# Decode
print(unquote(encoded))
# urlencode: build query strings
params = urlencode({'name':'Zhang San','city':'Beijing'})
print(params)URL Encoding/Decoding in Java
import java.net.URLEncoder;
import java.net.URLDecoder;
import java.net.URI;
import java.nio.charset.StandardCharsets;
public class URLEncodeExample {
public static void main(String[] args) throws Exception {
String encoded = URLEncoder.encode("Zhang San&Li Si", "UTF-8");
System.out.println(encoded);
String decoded = URLDecoder.decode(encoded, "UTF-8");
System.out.println(decoded);
URI uri = new URI("https","example.com","/search","q=hello",null);
System.out.println(uri.toASCIIString());
}
}FAQ
encodeURIComponent vs encodeURI?
encodeURIComponent encodes all non-safe characters including &, =, ? — suitable for individual parameter values. encodeURI preserves URL structural characters (: / ? #) — suitable for encoding complete URLs.
RFC 3986 vs standard encoding?
RFC 3986 treats tilde ~ as a safe unreserved character (not encoded), while older standards encode it as %7E. RFC 3986 reduces unnecessary escapes and improves URL readability.
When to use Query Only mode?
When you have a query string like ?name=张三&city=北京 and only want parameter values encoded, leaving keys and symbols intact. Output: ?name=%E5%BC%A0%E4%B8%89&city=%E5%8C%97%E4%BA%AC.
Should spaces be + or %20?
In application/x-www-form-urlencoded (HTML forms), spaces become +. In URL paths and encodeURIComponent, spaces always become %20. This tool uses %20 by default.
Why do different tools produce different results for Chinese?
It depends on character encoding. This tool uses UTF-8 (the Web standard). If another tool uses GBK, results will differ. Always use UTF-8 for Web URLs.
What does encoding highlight do?
Highlights %XX-encoded characters in amber, helping you understand encoding rules: letters/digits are safe and not encoded, while Chinese and special symbols are.
Does % itself need encoding?
Yes. % is the escape character — if a literal % appears in a parameter value, it must be encoded as %25, otherwise it will be misinterpreted as an encoded byte.
Glossary
- Percent-encoding
- The formal name for URL encoding, representing characters as % followed by two hex digits. Space→%20, 中→%E4%B8%AD.Wikipedia
- encodeURIComponent
- JavaScript built-in encoding all chars except A-Z a-z 0-9 - _ . ! ~ * ' ( ). Used for individual query parameter values.
- encodeURI
- JavaScript built-in preserving URL structural characters (: / ? # [ ] @ ! $ & ' ( ) * + , ; =), used for encoding complete URLs.
- RFC 3986
- The current IETF URI standard (2005) defining URL encoding rules, classifying ~ as unreserved. Replaces RFC 2396/1738.RFC 3986
- Reserved Characters
- Characters with special meaning in URLs (: / ? # [ ] @ ! $ & etc.) that must be encoded when used as data but not in their structural roles.
- Unreserved Characters
- Characters safe anywhere in URLs without encoding: A-Z, a-z, 0-9, -, _, ., ~ (per RFC 3986).
- Query String
- The part of a URL after ?, consisting of key=value pairs separated by &.
- URLSearchParams
- Modern browser API for safely building/parsing query strings with automatic encoding.
- application/x-www-form-urlencoded
- HTML form submission format where spaces become + instead of %20. Server frameworks usually handle both.
- UTF-8 Encoding
- The Web standard. Non-ASCII characters (Chinese, emoji) are first converted to UTF-8 byte sequences, then each byte is %XX-encoded.
Character Encoding Comparison Across 4 Modes
| Character | Description | encodeURIComponent | encodeURI | RFC 3986 |
|---|---|---|---|---|
space | Space | %20 | %20 | %20 |
! | Exclamation | %21 | ! | %21 |
# | Fragment | %23 | # | %23 |
& | Param separator | %26 | & | %26 |
' | Single quote | %27 | ' | %27 |
( | Left paren | %28 | ( | %28 |
) | Right paren | %29 | ) | %29 |
* | Asterisk | %2A | * | %2A |
+ | Plus | %2B | + | %2B |
/ | Path separator | %2F | / | %2F |
: | Colon | %3A | : | %3A |
; | Semicolon | %3B | ; | %3B |
= | Equals | %3D | = | %3D |
? | Query string | %3F | ? | %3F |
@ | At sign | %40 | @ | %40 |
~ | Tilde | %7E | %7E | ~ |
Common URL Reserved Characters Quick Reference
| Encoded | Char | URL Purpose |
|---|---|---|
%20 | (space) | Space |
%23 | # | Fragment identifier (hash) |
%25 | % | Escape character itself |
%26 | & | Query parameter separator |
%2B | + | Plus / form space |
%2F | / | Path separator |
%3A | : | Scheme separator |
%3D | = | Key-value separator |
%3F | ? | Query string start |
%40 | @ | Auth/email separator |
Authoritative References
- Secure String Comparison
- Binary Converter
- Caesar Cipher
- Morse Code Translator
- Hex Converter
- Video to Base64
- Base64 to Video
- Image to Base64
- Base64 to Image
- Text to Base64
- Base64 to Text
- File Hash Checker
- File to Base64
- Base64 to File
- Audio to Base64
- Base64 to Audio
- AES Encrypt / Decrypt
- DES Encrypt Decrypt
- Base32 Encoder Decoder
- Base58 Encode Decode
- Base64 Encode
- Base64 Decode
- Base64 Diff Checker
- Base64 Split
- Base64 Multi-line Merge
- Base64 Formatter
- Base64 Validation
- Base64 Batch Encode
- Base64 Batch Decoder
- Base64 Cleaner
- Base64 Padding Tool
- Base64 Length Statistics
- Base64 to HEX
- Base64 DataURL Converter
- Base64-Hex Converter
- Base85 Encoder
- HMAC Generator & Verifier
- PBKDF2 Key Derivation
- MD5 Hash
- SHA-256 Hash
- SHA1 Hash
- SHA512 Hash
- JWT Decode, Verify & Generate
- HTML Encode Decode
- Unicode Escape
- URL Encode
- URL Safe Base64
- MIME Base64
- Java Obfuscator
- JS Obfuscator
- PHP Obfuscator
- Python Obfuscator