Encode a search query
hello world & more
hello%20world%20%26%20more
Spaces become %20, and the & becomes %26 so it isn't mistaken for a query-parameter separator.
Safely encode and decode URL components.
Last updated
A URL encoder (also called percent-encoder or URI encoder) replaces characters that are reserved or unsafe in URLs with % followed by two hex digits. Developers reach for it when building query strings, escaping path segments, sharing URLs that contain spaces or non-ASCII characters, and debugging redirects.
URLs are restricted to a small set of ASCII characters. Anything outside that set — spaces, accents, emoji, or reserved symbols like ?, #, &, = when used in data — must be percent-encoded so it survives the trip from the browser to the server.
JavaScript exposes two encoding functions: encodeURI (preserves URL structure: /, ?, #, &) and encodeURIComponent (encodes everything reserved). Use encodeURIComponent for *values* you stuff into query strings, and encodeURI for *whole URLs* you want to keep functional.
% plus two hex digits — for example, a space becomes %20.: / ? # & = +) have meaning in URL structure. They must be encoded when used as data, not as separators.Choose Encode if you have raw text and want it URL-safe. Choose Decode if you have a %-encoded string and want the original text back.
Pick encodeURIComponent (encodes everything reserved) for query string values; pick encodeURI (keeps structure) for whole URLs.
Paste the raw text or the encoded URL. Multiline input works for batch decoding.
Copy the encoded or decoded value. The conversion runs locally in your browser, so secrets in URLs stay on your machine.
Characters you'll see encoded most often, with their percent-encoded form. Reserved character semantics come from RFC 3986.
| Character | Encoded | Why |
|---|---|---|
| space | %20 | Spaces aren't allowed in URLs |
! | %21 | Reserved by some servers |
# | %23 | Marks the start of a fragment |
$ | %24 | Reserved character |
& | %26 | Separates query parameters |
+ | %2B | Means space in form-encoded bodies |
/ | %2F | Path separator |
: | %3A | Separates scheme and host |
= | %3D | Separates key from value in query string |
? | %3F | Marks the start of the query string |
@ | %40 | Separates userinfo and host |
| UTF-8 byte | %C3%A9 | Each non-ASCII byte is encoded |
hello world & more
hello%20world%20%26%20more
Spaces become %20, and the & becomes %26 so it isn't mistaken for a query-parameter separator.
café
caf%C3%A9
é is the UTF-8 byte sequence 0xC3 0xA9, so the encoded form has *two* %XX groups for that single character.
https://example.com/path?q=hello world
https://example.com/path?q=hello%20world
https%3A%2F%2Fexample.com%2Fpath%3Fq%3Dhello%20world
encodeURI keeps URL structure intact (slashes, ?, =). encodeURIComponent encodes everything reserved — use it on values you put inside a query string, never on a whole URL.
encodeURI for query string values — the & and = survive the encoding and break parameter parsing.%2520 instead of %20 is the classic sign of double-encoding bugs.+ means space in application/x-www-form-urlencoded bodies but is a literal + in a URL path or query.% followed by two hex digits.encodeURI preserves URL structure characters (/, ?, #, &, =, +). encodeURIComponent encodes them all, which is what you want for individual *values* placed inside a URL — query parameter values, path segments, fragments. See the MDN references for encodeURI and encodeURIComponent.%20?%20, the percent-encoding of the ASCII space character (0x20 in hex).decodeURI, decodeURIComponent, or any URL-decoder reverses the percent-encoding back to the original characters.