URL Encoder Online – The Ultimate Guide to URL Encoding & Decoding (2025)
A URL encoder online converts spaces, special characters, and non-ASCII text into safe percent-encoded sequences — instantly. This guide explains every encoding rule, every function, and every mistake developers make.
What is a URL Encoder Online?
A URL encoder online is a browser-based tool that converts any text or URL into percent-encoded format — instantly, without installing anything. You paste your raw URL or query string, click encode, and get back a URL-safe string ready to use in your application or API request.
URLs can only contain a limited set of safe ASCII characters — letters (A–Z, a–z), digits (0–9), and a few symbols (-, _, ., ~). Every other character must be percent-encoded: replaced with a % followed by two hex digits. This process is formally called percent-encoding, standardized in RFC 3986 by the IETF.
For example, a space becomes %20, a + becomes %2B, and / becomes %2F. Any reliable URL encoder online handles all of these automatically.
URLs were designed in the early 1990s and limited to ASCII characters. As the web went global, developers needed to encode spaces, non-Latin scripts (Arabic, Chinese, etc.), and special characters into URLs without breaking HTTP parsers. A URL encoder online solves this by converting any byte into its safe percent-hex representation automatically.
How Percent-Encoding Works — The Rules Every URL Encoder Uses
The formula is simple: take the ASCII or UTF-8 byte value of the character, convert it to hexadecimal, and prefix with %. Every URL encoder online applies this same rule — the difference is which characters it encodes by default.
| Character | Encoded | Name | Notes |
|---|---|---|---|
| Space | %20 | Space | Always encode in URLs |
| + | %2B | Plus sign | Encode in query values (+ means space in forms) |
| / | %2F | Slash | Encode in query params only (path separator otherwise) |
| ? | %3F | Question mark | Encode in param values (query separator otherwise) |
| & | %26 | Ampersand | Encode in param values (param separator otherwise) |
| = | %3D | Equals sign | Encode in param values (key=value separator otherwise) |
| # | %23 | Hash | Encode in params (fragment identifier otherwise) |
| @ | %40 | At sign | Encode in URLs (user info separator) |
| % | %25 | Percent | Always encode (starts percent sequences) |
| ا | %D8%A7 | Arabic Alef | Non-ASCII: encode UTF-8 bytes |
| – | – | Hyphen | Safe — never encode |
| _ | _ | Underscore | Safe — never encode |
| . | . | Period | Safe — never encode |
| ~ | ~ | Tilde | Safe — never encode |
When to Encode vs Decode — Choosing the Right Direction
- 📨 Building query parameters from user input
- 🔗 Embedding URLs inside other URLs
- 📝 Passing non-ASCII text in GET requests
- 🗂️ Encoding file names with spaces in URLs
- 🌐 Sending Arabic/Urdu/Chinese text in URLs
- 📤 Constructing API requests programmatically
- 📥 Reading query parameters from server logs
- 🔍 Displaying URLs to users in readable form
- 🛠️ Debugging encoded API requests
- 📂 Extracting readable file names from URLs
- 🔎 Reading encoded search queries in analytics
- 📋 Copy-pasting encoded URLs for human review
URL Encoding in Code — JavaScript, Python, PHP
Every major language has a built-in URL encoder. Use these instead of a manual URL encoder online when you need to encode dynamically at runtime.
JavaScript — Three Functions You Must Know
| Function | What It Encodes | When to Use |
|---|---|---|
| encodeURIComponent() | Everything except: A–Z a–z 0–9 – _ . ! ~ * ‘ ( ) | ✓ Query param values, form data |
| encodeURI() | Encodes less — preserves : / ? # @ & = + $ , ; | Full URL encoding (preserves URL structure) |
| escape() | Legacy function, does not handle Unicode properly | ✗ Never use — deprecated |
JavaScript — URL Encoder
// ✅ Encode a query parameter value
const query = "hello world & more";
const encoded = encodeURIComponent(query);
// → "hello%20world%20%26%20more"
// ✅ Build a URL safely with URLSearchParams
const base = "https://example.com/search";
const params = new URLSearchParams({
q: "hello world",
lang: "urdu",
page: 1
});
const url = `${base}?${params.toString()}`;
// → https://example.com/search?q=hello+world&lang=urdu&page=1
// ✅ Decode a URL parameter
const raw = "hello%20world%20%26%20more";
const decoded = decodeURIComponent(raw);
// → "hello world & more"
// ✅ Parse URL parameters from current page
const urlParams = new URLSearchParams(window.location.search);
const searchQuery = urlParams.get('q'); // Already decoded!
Python — URL Encoder
Python — URL Encoder
from urllib.parse import quote, unquote, urlencode, urljoin
# Encode a query string value with Python
query = "hello world & more"
encoded = quote(query, safe='')
# → "hello%20world%20%26%20more"
# Decode a percent-encoded string
decoded = unquote("hello%20world%20%26%20more")
# → "hello world & more"
# Build URL with query parameters
params = {'q': 'hello world', 'lang': 'urdu', 'page': 1}
query_string = urlencode(params)
url = f"https://example.com/search?{query_string}"
# Encode non-ASCII (Arabic text)
arabic = "مرحبا"
enc_arabic = quote(arabic)
# → "%D9%85%D8%B1%D8%AD%D8%A8%D8%A7"
PHP — URL Encoder
PHP — URL Encoder
// PHP — urlencode vs rawurlencode
$query = "hello world & more";
$encoded = urlencode($query);
// → "hello+world+%26+more" (spaces become +)
$encoded_raw = rawurlencode($query);
// → "hello%20world%20%26%20more" (spaces become %20)
// Decode
$decoded = urldecode($encoded);
$raw_decoded = rawurldecode($encoded_raw);
// Build a URL safely
$params = ['q' => 'hello world', 'lang' => 'urdu'];
$url = 'https://example.com/search?' . http_build_query($params);
Common URL Encoding Mistakes to Avoid
Even experienced developers make these errors. A good tool handles them automatically — but you need to understand them when coding manually.
Double-encoding URLs
Running an already-encoded string through the tool again turns %20 into %2520. Always check if a string is already encoded before encoding again.
Encoding the entire URL instead of just the parameters
Using encodeURIComponent() on a full URL encodes the slashes and colons, breaking it. Use encodeURI() for full URLs or URLSearchParams for parameters.
Confusing + and %20 for spaces
HTML forms encode spaces as +. Raw percent-encoding uses %20. They are not interchangeable — + is only a space in query strings, not in paths. RFC 3986 encoding always produces %20.
Not encoding URLs before embedding in HTML
When you put a URL inside an href attribute, & must be HTML-entity-encoded separately from URL encoding. An unescaped & in HTML breaks the attribute.
The safest approach — whether building by hand or in code — is to use URLSearchParams in JavaScript, urlencode() in PHP, or requests.get(url, params=dict) in Python. These handle encoding automatically and prevent injection bugs. See the MDN URLSearchParams documentation for full API reference.
Frequently Asked Questions
Here are the most common questions developers ask about URL encoding.
Free URL Encoder Online — Instant Results
Paste any URL or text and get the encoded output instantly. Handles UTF-8, non-ASCII, and all special characters. Free, private, browser-based.