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.
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.
encodeURIComponent encodes all non-safe characters including &, =, ? — suitable for individual parameter values. encodeURI preserves URL structural characters (: / ? #) — suitable for encoding complete URLs.
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 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.
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.
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.
Highlights %XX-encoded characters in amber, helping you understand encoding rules: letters/digits are safe and not encoded, while Chinese and special symbols are.
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.
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.
| 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 | ~ |
| 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 |
// 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());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)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());
}
}