How URL encoding works
A URL may only contain a limited set of ASCII characters, and a few of those — like ?, &, =, and / — carry structural meaning. URL encoding (percent-encoding, per RFC 3986) lets you put arbitrary text into a URL by replacing unsafe characters with a % and the character's hexadecimal byte value, so a space becomes %20.
The key decision is scope. encodeURIComponent escapes everything that isn't an unreserved character — including the separators — which is exactly what you want for a single query value or path segment. encodeURI deliberately leaves the separators alone so a whole URL stays functional. Reaching for the wrong one is the most common URL-encoding mistake.
Everything runs locally in your browser, so the text and URLs you paste never leave the page.
Component vs. Full URI
encodeURIComponent — escapes / ? & = # too. For one value going inside a URL.
encodeURI — preserves URL structure. For encoding a complete URL as a whole.
Where developers use it
Building a query string
Encode a search term with spaces and symbols before appending it as ?q=… so the link doesn't break.
Reading a redirect param
Decode a percent-encoded return URL nested inside another link to see exactly where it points.
Passing JSON in a URL
Encode a small JSON blob into a single query value, then decode it on the other side.
Frequently asked questions
It replaces characters that aren't safe in a URL with a % followed by their hexadecimal byte value — so a space becomes %20 and & becomes %26. This is also called percent-encoding, defined in RFC 3986.
Use Component (encodeURIComponent) for a single piece going into a URL — one query value, a path segment — because it escapes structural characters like / ? & = #. Use Full URI (encodeURI) on a whole URL you want to keep working, since it leaves those separators intact. Encoding a query value with Full URI is the classic bug.
In the path and most contexts a space is %20. In application/x-www-form-urlencoded data — HTML form submissions and query strings — a space may be encoded as + instead. They mean the same thing in that one context; this tool uses the standard %20.
Decoding throws a URIError when the input has a malformed percent sequence — a % not followed by exactly two valid hex digits (0–9, A–F). It usually means the string was truncated, double-encoded, or wasn't percent-encoded at all. Make sure the input is intact and encoded once before decoding.
No. Unreserved characters — letters, digits, and - _ . ~ — are always safe and stay as-is. Only reserved and unsafe characters get percent-encoded, which keeps URLs readable.
Yes. Input is handled as UTF-8: each non-ASCII character is converted to its UTF-8 bytes and percent-encoded as a sequence of hex blocks, so accented letters, Chinese/Japanese/Korean text, and emoji round-trip correctly.
No. Encoding and decoding happen entirely in your browser; nothing is uploaded.