URL Encode / Decode
Encode or decode URL components. Supports both encodeURIComponent (for query params) and encodeURI (for full URLs).
Output will appear here…Component encodes all special characters including /, ?, &. Use for query parameter values. Full URI preserves URL structure characters. Use for full URLs.
encodeURIComponent vs encodeURI — when to use each
RFC 3986 defines which characters are safe in URLs. JavaScript provides two built-in functions for URL encoding:
| Function | Encodes | Use for |
|---|---|---|
| encodeURIComponent | Everything except A-Z a-z 0-9 - _ . ! ~ * ' ( ) | Query parameter values, hash fragments, form data |
| encodeURI | Preserves : / ? & = @ # and more | Full URLs where you want to keep structure intact |
URL encoding in different languages
// JavaScript — encoding query parameters
const q = "hello world & more";
encodeURIComponent(q); // → "hello%20world%20%26%20more"
// Building a URL safely
const base = "https://api.example.com/search";
const url = base + "?q=" + encodeURIComponent(q) + "&lang=en";
// URLSearchParams (recommended for query strings)
const params = new URLSearchParams({ q, lang: "en", page: "1" });
fetch(base + "?" + params.toString());
// Python
from urllib.parse import quote, urlencode
quote("hello world") # → "hello%20world"
urlencode({"q": "hello world", "n": 5}) # → "q=hello+world&n=5"
// Go
import "net/url"
url.QueryEscape("hello world") // → "hello+world"
url.PathEscape("hello world") // → "hello%20world"
// PHP
urlencode("hello world"); // → "hello+world"
rawurlencode("hello world"); // → "hello%20world"Common characters and their encoded forms
Related Tools
Frequently Asked Questions
What is URL encoding?
URL encoding (percent encoding) replaces unsafe ASCII characters with a '%' followed by their hex value. For example, spaces become %20 and & becomes %26. It ensures URLs are transmitted correctly over the internet as defined in RFC 3986.
What is the difference between encodeURI and encodeURIComponent?
encodeURI preserves URL structure characters like /, ?, &, and = — use it for encoding full URLs. encodeURIComponent encodes everything including those characters — use it for encoding individual query parameter values.
Does this handle Unicode characters?
Yes. Both encoding modes properly handle Unicode characters including emojis, accented characters, and CJK scripts by first encoding them as UTF-8 bytes, then percent-encoding each byte.
Is my data safe?
Yes. All encoding and decoding happens entirely in your browser using JavaScript's built-in functions. No data is sent to any server.
Why do spaces appear as %20 sometimes and + other times?
In URL paths and modern encoding, spaces become %20. In HTML form submissions (application/x-www-form-urlencoded), spaces become +. Both are valid — %20 is the standard per RFC 3986, while + is a legacy HTML form convention.
When should I URL encode?
URL encode any user-provided string before inserting it into a URL: search queries, filenames, redirect URLs, API parameters, and any value that might contain special characters like &, =, #, or spaces.
Does this URL encoder work offline?
Yes. Once the page is loaded, it runs 100% client-side in your browser and works without an internet connection.