URL Encoder / Decoder/ Encode · Decode · Form

Encode and decode URLs using encodeURIComponent, encodeURI, or form encoding — handles CJK and special chars.

Encode all special chars (recommended, for query param values)

Plain Text
0 chars
Encoded
Size ratio: —%0 chars
Common encodings
%20 / +
!%21
"%22
#%23
%%25
&%26
'%27
+%2B
/%2F
=%3D
?%3F
@%40

Did this tool solve your problem?

What is URL encoding

URL encoding (Percent-encoding) converts special characters to `%` followed by two hex digits. URLs only allow letters, numbers, and a few symbols (`-_.~`). Other characters like space (%20) or non-ASCII characters must be encoded. Browsers auto-encode URLs in the address bar, but you need to handle encoding manually when building URLs programmatically.

Common URL encoding scenarios

Passing special characters in query parameters (e.g., search terms containing `&` or `=`), form data submission (POST defaults to URL encoding), API requests with JSON or non-ASCII parameters, and OAuth callback URLs. Use `encodeURIComponent()` in JavaScript or `urllib.parse.quote()` in Python.

Code Examples

JavaScript
// Encode a query parameter value
encodeURIComponent("Hello World! 中文")
// "Hello%20World!%20%E4%B8%AD%E6%96%87"

// Build a full query string (recommended)
const params = new URLSearchParams({
  q: "hello world",
  lang: "zh-CN",
  page: "1",
});
params.toString()
// "q=hello+world&lang=zh-CN&page=1"

// Decode
decodeURIComponent("Hello%20World%21")
// "Hello World!"
Python
from urllib.parse import (
    quote, unquote,
    urlencode, quote_plus
)

# Encode single value
quote("Hello World! 中文")
# 'Hello%20World%21%20%E4%B8%AD%E6%96%87'

# Form encoding (spaces → +)
quote_plus("hello world")
# 'hello+world'

# Build query string
urlencode({"q": "hello world", "page": 1})
# 'q=hello+world&page=1'

# Decode
unquote("Hello%20World%21")  # 'Hello World!'
Go
import "net/url"

// Encode a path segment
url.PathEscape("hello world/中文")
// "hello%20world%2F%E4%B8%AD%E6%96%87"

// Encode a query value
url.QueryEscape("hello world")
// "hello+world"

// Build query string
params := url.Values{}
params.Set("q", "hello world")
params.Set("lang", "zh-CN")
params.Encode()
// "lang=zh-CN&q=hello+world"

// Parse a URL
u, _ := url.Parse("https://example.com/search?q=hello+world")
u.Query().Get("q")  // "hello world"
Shell (curl)
# curl handles encoding automatically with --data-urlencode
curl -G https://api.example.com/search \
  --data-urlencode "q=hello world 中文" \
  --data-urlencode "page=1"

# Manual percent-encoding with Python
python3 -c "
import sys
from urllib.parse import quote
print(quote(sys.stdin.read().strip()))
" <<< "hello world 中文"

# Using jq to build encoded JSON body
curl -X POST https://api.example.com \
  -H 'Content-Type: application/json' \
  -d "$(jq -n --arg q 'hello world' '{query: $q}')"

Frequently Asked Questions

What's the difference between encodeURIComponent and encodeURI?
encodeURIComponent encodes almost all special characters (including :/?#[]@!$&'()*+,;=) and is used for individual query parameter values. encodeURI preserves URL structural characters, making it suitable for encoding a complete URL without breaking its structure. Use encodeURIComponent in most cases.
What is form encoding (application/x-www-form-urlencoded)?
Form encoding is the default format for HTML form submissions. The only difference from encodeURIComponent is that spaces become + instead of %20. Browsers use this automatically for <form> submissions, and many APIs also accept request bodies in this format.
Why can't URLs contain non-ASCII characters?
The URL spec (RFC 3986) only allows ASCII characters. Non-ASCII characters like CJK must first be UTF-8 encoded into a byte sequence, then each byte is written as %XX. For example, the Chinese character 中 encodes to %E4%B8%AD in a URL.
Which characters don't need URL encoding?
RFC 3986's 'unreserved characters' never need encoding: letters (A-Z, a-z), digits (0-9), and the four symbols - _ . ~. Within specific URL components, some reserved characters are also allowed, but it's generally safer to percent-encode all non-alphanumeric characters for maximum compatibility.
Both %20 and + represent a space — what's the difference?
%20 is the universal URL encoding for a space, valid anywhere in a URL. The + sign only means 'space' in query strings under the application/x-www-form-urlencoded convention — in URL paths, + means a literal plus sign. Using %20 universally avoids ambiguity.
How do I correctly build URL query strings in JavaScript?
Use the URLSearchParams API: new URLSearchParams({ key: value }).toString() handles encoding automatically. Alternatively, manually encode each value with encodeURIComponent(value) when concatenating. Never concatenate raw unencoded strings — it leads to injection vulnerabilities and parse errors.