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)
%20 / +!%21"%22#%23%%25&%26'%27+%2B/%2F=%3D?%3F@%40Did 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
// 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!"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!'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"# 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}')"