URL Encoder Online – The Ultimate Guide to URL Encoding & Decoding (2025)
url encoder online percent encoding diagram
Decoded (Human-readable)
https://example.com/search?q=hello world&lang=urdu&price=10+20
↓ URL Encoder Online ↓
Encoded (URL-safe)
https://example.com/search?q=hello%20world&lang=urdu&price=10%2B20

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.

💡
Why Does URL Encoding Exist?

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.

CharacterEncodedNameNotes
Space%20SpaceAlways encode in URLs
+%2BPlus signEncode in query values (+ means space in forms)
/%2FSlashEncode in query params only (path separator otherwise)
?%3FQuestion markEncode in param values (query separator otherwise)
&%26AmpersandEncode in param values (param separator otherwise)
=%3DEquals signEncode in param values (key=value separator otherwise)
#%23HashEncode in params (fragment identifier otherwise)
@%40At signEncode in URLs (user info separator)
%%25PercentAlways encode (starts percent sequences)
ا%D8%A7Arabic AlefNon-ASCII: encode UTF-8 bytes
HyphenSafe — never encode
__UnderscoreSafe — never encode
..PeriodSafe — never encode
~~TildeSafe — never encode

When to Encode vs Decode — Choosing the Right Direction

→ URL Encoder Online
  • 📨 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
← URL Decoder
  • 📥 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

FunctionWhat It EncodesWhen 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.

01

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.

❌ encodeURIComponent(“hello%20world”) → “hello%2520world”
✅ encodeURIComponent(“hello world”) → “hello%20world”
02

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.

❌ encodeURIComponent(“https://example.com/path?q=hi”) → “https%3A%2F%2F…”
✅ new URLSearchParams({q: “hi”}).toString() → “q=hi”
03

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.

❌ Using + in a URL path: /files/my+document.pdf → “my+document.pdf”
✅ In URL path: /files/my%20document.pdf → “my document.pdf”
04

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.

❌ <a href=”?q=a&b=c”> — & breaks HTML parsing
✅ <a href=”?q=a&b=c”> — proper HTML entity encoding
⚠️
Never Build URLs by String Concatenation

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.

What is the difference between URL encoding and HTML encoding?
URL encoding (percent-encoding) converts characters to %XX format for safe use in URLs — e.g. space → %20. HTML encoding converts characters to HTML entities — e.g. < → &lt;. A URL encoder online handles URL encoding only. Both are required in different contexts: URL encode query parameter values, HTML encode text content in markup.
Why does space sometimes become + and sometimes %20?
HTML forms encode spaces as + (application/x-www-form-urlencoded). Raw percent-encoding uses %20. Most tools let you choose: URLSearchParams and form submissions use +. encodeURIComponent() uses %20. In URL paths, only %20 is correct — + is a literal plus sign in paths.
How do I encode non-ASCII text like Arabic or Chinese in a URL?
Non-ASCII characters are first encoded as UTF-8 bytes per RFC 3629, then each byte is percent-encoded. For example, مرحبا encodes as %D9%85%D8%B1%D8%AD%D8%A8%D8%A7. Any good tool handles this automatically — as does encodeURIComponent() in JavaScript and quote() in Python.
What is URL encoding used for in security?
Proper URL encoding prevents certain injection attacks where malicious input manipulates URL structure. However, URL encoding alone is not sufficient — always validate and sanitize input server-side. Attackers can bypass filters using double-encoding. Never rely on a URL encoder online as a security control on its own.
Should I encode slashes in file paths in URLs?
In URL paths, slashes / are path separators and should NOT be encoded. If a file name contains a slash, encode it as %2F. In query parameter values, always encode slashes. Some servers block %2F in paths by default — check your configuration. Most tools give you control over whether to encode slashes.

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.

Share.
Leave A Reply