URL Encode
URL Encoder & Decoder is a free browser-based tool that percent-encodes special characters in URLs and query strings, or decodes %XX sequences back to readable text. It supports three modes: Component (encodeURIComponent for query values), Full URL (encodeURI for complete URLs), and Form encoding (application/x-www-form-urlencoded with + for spaces). No data is ever sent to a server.
URL Encoder & Decoder
How it works
Last updated: November 2026URL encoding (percent encoding) converts characters that are not allowed in URLs — such as spaces, &, =, and non-ASCII characters — into a % followed by two hex digits. For example, a space becomes %20 and & becomes %26.
Paste any text into the left panel, choose a mode, and click Encode or Decode. Three modes are available:
- Component — encodes everything except letters, digits, and
-_.!~*'(). Use this for individual query parameter values (encodeURIComponent). - Full URL — encodes only characters that cannot appear anywhere in a URL, preserving
/,?,&,=, and#. Use this for a complete URL (encodeURI). - Form (+) — like Component, but encodes spaces as
+instead of%20. This is the format produced by HTML form submissions (application/x-www-form-urlencoded).
All processing runs in your browser using JavaScript's built-in encodeURIComponent and decodeURIComponent APIs. Nothing is sent to any server.
URL Encoding Reference
| Character | Encoded | Notes |
|---|---|---|
| space | %20 or + | %20 everywhere; + only in form data |
| & | %26 | Must encode in query param values |
| = | %3D | Must encode in query param values |
| + | %2B | Encode if value contains a literal + |
| # | %23 | Fragment identifier — encode in values |
| % | %25 | Always encode literal % to avoid double-encoding |
| / | %2F | Encode in values; Component mode encodes this |
Safe (unreserved) characters — never encoded
A–Z a–z 0–9 - _ . ~
Tips & Tricks
Use URLSearchParams instead of manual encoding
new URLSearchParams({ key: value }).toString() handles all edge cases automatically — including + for spaces, encoding &, =, and #. It's safer than calling encodeURIComponent yourself and joining with &.
Double-encoding is a silent bug
Encoding an already-encoded string turns %20 into %2520. The server decodes %2520 to %20 (not a space), so the value arrives wrong. Always encode raw strings, never pre-encoded ones.
encodeURI won't encode & or = — use Component for values
encodeURI("?q=a&b=c") returns ?q=a&b=c unchanged because & and = are reserved URI characters. If your query value contains & or =, always use encodeURIComponent on the value before building the URL string.
+ is only a space in query strings
The + → space conversion applies only to application/x-www-form-urlencoded data (query strings from HTML forms). In a URL path, + is a literal plus sign. decodeURIComponent('+') === '+', not a space. Use decodeURIComponent(str.replace(/\+/g, '%20')) when decoding form data.
Path segments need different encoding than query params
In a URL path like /users/john doe, the space encodes as %20, never +. Query params from forms use +. Many bugs arise from applying form encoding to path segments — always use Component mode or %20 for paths.
curl --data-urlencode handles encoding for you
curl -G "https://api.example.com/search" --data-urlencode "q=hello world" encodes the value and appends it as a query string automatically. No need to manually escape — useful when testing APIs with special characters in parameters.
Code Examples
Node.js / JavaScript
const { URLSearchParams } = require('url');
// Encode query parameters (recommended for form data)
const params = new URLSearchParams({ q: 'hello world', lang: 'en' });
console.log(params.toString());
// q=hello+world&lang=en
// encodeURIComponent — encode a single value
const value = encodeURIComponent('price: $10 & tax');
console.log(value);
// price%3A%20%2410%20%26%20tax
// Decode
console.log(decodeURIComponent('price%3A%20%2410%20%26%20tax'));
// price: $10 & tax Python
from urllib.parse import quote, unquote, urlencode, parse_qs
# Encode a single value (like encodeURIComponent)
encoded = quote("hello world & more", safe='')
print(encoded) # hello%20world%20%26%20more
# Encode query params (spaces → +)
params = urlencode({"q": "hello world", "lang": "en"})
print(params) # q=hello+world&lang=en
# Decode
print(unquote("hello%20world")) # hello world
print(unquote_plus("hello+world")) # hello world CLI
# Encode with Python one-liner
python3 -c "import urllib.parse; print(urllib.parse.quote('hello world & more', safe=''))"
# hello%20world%20%26%20more
# Decode
python3 -c "import urllib.parse; print(urllib.parse.unquote('hello%20world%20%26%20more'))"
# hello world & more
# Encode with Node.js
node -e "console.log(encodeURIComponent('hello world & more'))"
# hello%20world%20%26%20more
# curl handles encoding automatically
curl -G "https://api.example.com/search" --data-urlencode "q=hello world" Frequently Asked Questions
- What is URL encoding?
- URL encoding (percent encoding, defined in RFC 3986) converts characters that are not allowed or have reserved meaning in URLs — such as spaces, &, =, and non-ASCII characters — into a
%followed by two uppercase hexadecimal digits representing the byte value. For example, a space (byte 0x20) becomes%20, an ampersand (byte 0x26) becomes%26, and the euro sign € (UTF-8 bytes 0xE2 0x82 0xAC) becomes%E2%82%AC. The goal is to ensure that URLs remain valid ASCII strings that can be transmitted safely over all internet protocols, including older systems that only handle 7-bit ASCII. Non-ASCII characters are first converted to UTF-8 bytes, then each byte is percent-encoded. The unreserved characters — A–Z, a–z, 0–9, hyphen, underscore, dot, and tilde — are never encoded and are always safe to include in a URL. - What is the difference between encodeURI and encodeURIComponent?
encodeURIencodes a complete URL and deliberately leaves the characters that give a URL its structure unencoded:; , / ? : @ & = + $ # - _ . ! ~ * ' ( ). Use it when you have a full URL and want to fix non-ASCII characters without breaking the structure.encodeURIComponentencodes everything except letters, digits, and- _ . ! ~ * ' ( )— including/,?,&, and=. This makes it the correct function for encoding individual query parameter values before inserting them into a URL string. For example, to build a search URL safely:'https://example.com/search?q=' + encodeURIComponent('cats & dogs')produces?q=cats%20%26%20dogs. UsingencodeURIon that value would leave&unencoded, breaking the query string. TheURLSearchParamsclass is even safer for building multi-parameter query strings.- What is the difference between %20 and + for spaces?
- %20 is the standard percent-encoded representation of a space character (byte 0x20) and is valid in any part of a URL — the path, the query string, and fragment identifiers. The
+character represents a space only insideapplication/x-www-form-urlencodeddata, which is the format produced by HTML form submissions and theURLSearchParamsclass. If you use+as a space in a URL path segment, most servers will treat it as a literal plus sign, not a space — resulting in a 404 or unexpected routing. This distinction matters most when accepting user input that may contain spaces: a user searching for "New York" submitted via a form becomesq=New+York, but the same string in a URL path must be/cities/New%20York. When decoding form data in JavaScript, usedecodeURIComponent(str.replace(/\+/g, '%20'))to correctly interpret the+as a space. - Which characters need to be URL encoded?
- Characters that must always be encoded in query parameter values include: space (%20),
&(%26),=(%3D),+(%2B),#(%23),%(%25),/(%2F),?(%3F),@(%40), and all non-ASCII characters (which are first converted to UTF-8 bytes, then each byte percent-encoded). The safe unreserved characters that are never encoded — per RFC 3986 — are: A–Z, a–z, 0–9, hyphen (-), underscore (_), dot (.), and tilde (~). Characters like!,',(,), and*are technically unreserved but are encoded byencodeURIComponentfor extra safety. When in doubt, encoding a character with its percent-escaped form is always safe — over-encoding is preferable to leaving ambiguous characters unencoded. - What is double URL encoding?
- Double encoding happens when an already-encoded string is passed through a URL encoder a second time: the
%character (byte 0x25) in%20gets encoded to%25, producing%2520. When the server decodes%2520it gets the string%20instead of a space, corrupting the value silently. This is a common bug in middleware stacks where both the application layer and a proxy or framework independently perform URL encoding. Always encode raw, unencoded values exactly once — never pass a pre-encoded string toencodeURIComponent. A simple diagnostic: if you see%25in a URL that is supposed to represent a space, double-encoding has occurred. The fix is to decode the string withdecodeURIComponentonce before re-encoding it, or to audit which layer is responsible for encoding and ensure only one layer does it. - How do I URL encode in Python?
- Python's
urllib.parsemodule (standard library, no install needed) provides all the functions you need. Useurllib.parse.quote(value, safe='')to encode a single query parameter value — thesafe=''argument ensures that/and other reserved characters are encoded, equivalent to JavaScript'sencodeURIComponent. Useurllib.parse.quote_plus(value)for form encoding where spaces become+. Useurllib.parse.urlencode({'key': 'value', 'q': 'hello world'})to encode a dict of parameters into a full query string:key=value&q=hello+world. To decode, useurllib.parse.unquote(encoded)for percent-encoded strings orurllib.parse.unquote_plus(encoded)when+should be interpreted as a space. For parsing an existing query string,urllib.parse.parse_qs('q=hello+world')returns{'q': ['hello world']}. - How do I URL encode in JavaScript?
- JavaScript (both browser and Node.js) provides three built-in approaches. Use
encodeURIComponent(value)to encode a single query parameter value — it encodes everything except letters, digits, and- _ . ! ~ * ' ( ). UseencodeURI(url)to encode a full URL while preserving its structural characters. For building multi-parameter query strings, usenew URLSearchParams({'q': 'hello world', 'lang': 'en'}).toString()which producesq=hello+world&lang=enusing form encoding — this is the safest and most readable approach. To decode, usedecodeURIComponent('%20hello%20')which returns' hello '. For form-encoded strings with+as spaces, usedecodeURIComponent(str.replace(/\+/g, '%20')). TheURLconstructor (new URL(str)) can also parse and validate complete URLs and exposes the query string viaurl.searchParamsas aURLSearchParamsinstance. - How do I URL encode in Node.js?
- Node.js has the same
encodeURIComponentanddecodeURIComponentglobals as browsers. For building query strings, prefernew URLSearchParams({key: value}).toString()from the built-in 'url' module — it handles all edge cases and uses + for spaces (form encoding). For URL-safe strings without +, useencodeURIComponent. - What is application/x-www-form-urlencoded?
application/x-www-form-urlencodedis the defaultContent-Typefor HTML form submissions (whenenctypeis not set tomultipart/form-data). In this format, key-value pairs are joined with=, pairs separated by&, and spaces encoded as+instead of%20. The browser uses this format automatically when you submit a form via GET or POST. It is also the format produced by JavaScript'snew URLSearchParams({key: value}).toString()and Python'surllib.parse.urlencode({...}). To send it viafetchin a POST request, set the body to aURLSearchParamsobject — the browser sets the correctContent-Typeheader automatically. Server frameworks like Express.js, Django, and Flask parse this format out of the box using their body-parser or request middleware. The key difference from standard percent-encoding is only in the space character:+versus%20.- What is the Component mode in this tool?
- Component mode uses JavaScript's
encodeURIComponentunder the hood, which encodes everything except the unreserved characters: letters, digits, and- _ . ! ~ * ' ( ). This mode encodes/,?,&,=,#, and:— making it safe for encoding individual query parameter values or path segments before inserting them into a URL string. Use Component mode when you have a raw string value that needs to go into a URL, not a complete URL you want to preserve. Full URL mode usesencodeURIand leaves the structural URL characters intact, so it is appropriate when you have a complete URL with known-valid structure that just needs non-ASCII characters or spaces fixed. Form mode is identical to Component mode except spaces are encoded as+rather than%20, matching theapplication/x-www-form-urlencodedformat used by HTML forms. - Why does my URL look correct but the server receives wrong data?
- The most common cause is an unencoded
&or=inside a query parameter value. If your value contains a literal&— for example a product name like "Cookies & Cream" — and you append it to a URL without encoding, the server's query string parser interprets the&as a parameter separator and splits the value into two separate parameters:name=CookiesandCream(empty key). Similarly, an unencoded=confuses the key-value separator. The fix is straightforward: always encode values withencodeURIComponent(value)before string-concatenation, or usenew URLSearchParams({name: 'Cookies & Cream'}).toString()which handles all encoding automatically. This is especially easy to miss when values come from user input or database fields that may contain special characters. - Is my data sent to a server?
- No. All URL encoding and decoding runs entirely in your browser using JavaScript's built-in
encodeURIComponent,decodeURIComponent,encodeURI, anddecodeURIfunctions — no network requests are made and nothing is transmitted to any server. This matters because URL strings often contain sensitive data: API keys embedded in query parameters, authentication tokens, private file paths, or personal data in search terms. Keeping all processing local ensures that sensitive values are never exposed to a third-party service. You can confirm this by opening the browser's Network tab in DevTools and observing that no requests are made when encoding or decoding. No account, sign-up, or internet connection is required after the page has loaded.
Related Tools
Other free developer tools available on DevFormatter.
Base64 Encode / Decode
Encode text or binary data to Base64, or decode Base64 strings back to plain text. Supports Unicode and URL-safe Base64.
JSON Formatter
Format, validate, and minify JSON. Sort keys, find duplicates, and explore with Tree view.
YAML Formatter
Format, validate, and convert YAML. Detects YAML 1.1 coercion risks and expands anchors.
XML Formatter
Format, validate, and convert XML to JSON. All processing runs in your browser.