URL Encoder & Decoder
Percent-encode text for URLs or decode it back, with the choice between full-URI and component encoding explained.
How to use this calculator
- 1Pick encode or decode.
- 2For encoding, choose "component" when the text is going into a single query parameter, or "full URI" when it is a complete address.
- 3Paste your text and copy the result.
How the calculation works
Unsafe byte → % + two uppercase hex digits (e.g. space → %20)- %XX
- A percent sign followed by the byte value in hexadecimal
- Unreserved
- A–Z a–z 0–9 - _ . ~ are never encoded
Characters are UTF-8 encoded first, then each byte is escaped. This is why a single emoji becomes four escape sequences.
Reserved characters (: / ? # [ ] @ ! $ & ' ( ) * + , ; =) have structural meaning. Whether they should be escaped depends entirely on whether you are encoding a whole URL or one value inside it.
Worked example
Encoding a search query as a component
- 1.The space becomes %20 and the ampersand becomes %26.
- 2.Escaping the ampersand is essential — left raw, it would be read as the start of a new query parameter.
- 3.The result is hello%20world%20%26%20more.
Result: hello%20world%20%26%20more
Why URLs can’t contain arbitrary characters
A URL is plain ASCII text, but the data people want to put inside one — search terms, file names, whole sentences — routinely includes spaces, punctuation, accented letters and symbols the URL syntax has already claimed for its own structure. A slash marks a path segment, a question mark starts the query string, an ampersand separates one parameter from the next, and a hash marks a fragment. If a value being inserted into a URL happened to contain one of those characters unescaped, there would be no reliable way to tell where the structure ends and the data begins.
Percent-encoding is the fix: any byte can be represented as a percent sign followed by its two-digit hexadecimal value, so a value can carry literally any character while staying inside the narrow set of characters a URL is allowed to use.
How the encoding actually works
Encoding starts by turning the text into bytes — almost always UTF-8, which is why one accented letter or emoji can expand into two, three or four percent-encoded sequences rather than one. Every byte that falls outside a small “unreserved” set — the letters A–Z and a–z, the digits 0–9, and the four symbols - _ . ~ — is then replaced with %XX, where XX is that byte’s value in hex.
Everything else depends on where the text is going. A single value destined for one query parameter should have every reserved character escaped too, since an unescaped & or = inside it would be read as the start of a new parameter. A complete URL should keep its structural characters — :, /, ?, #, and so on — untouched, or the browser has no way to parse it as a URL at all. That is the practical difference between component encoding and full-URI encoding.
Where percent-encoding shows up
It surfaces almost anywhere user-supplied or dynamic text ends up as part of a link:
- Search boxes — a query like "coffee shops near me" becomes coffee%20shops%20near%20me in the address bar, because the URL syntax has no other way to carry a literal space.
- Redirect and "return to" links — a login page that needs to send you back to /account/settings?tab=billing after signing in has to encode that whole path as a single query value, or its own slashes and question mark would collide with the login URL’s.
- Sharing and tracking links — social share buttons and marketing links routinely encode a full destination URL as one parameter, e.g. ?url=https%3A%2F%2Fexample.com%2Fpost, so it can travel through another URL without breaking it.
- Non-ASCII text in URLs — file names, usernames or search terms in scripts outside basic ASCII are UTF-8 encoded first, which is why a URL containing, say, Japanese or Cyrillic characters looks like a long run of %XX sequences once encoded.
Mistakes worth watching for
A handful of errors account for most broken links and mangled data:
- Double-encoding — running an already-encoded string through the encoder again turns every % into %25, corrupting the value. If a % followed by two hex digits already appears in your input, it is very likely already encoded.
- Encoding a whole URL with component scope — component encoding escapes :, / and ? along with everything else, so applying it to a complete address turns https://example.com into an unusable blob rather than a working link.
- Mistaking encoding for security — percent-encoding is a reversible, publicly documented transformation — anyone can decode it instantly, by hand if needed. It hides nothing and adds no confidentiality; it only makes data safe to embed inside URL syntax, not safe to expose.
- The + versus %20 mismatch — form submissions encode a space as +, while general percent-encoding uses %20. Decoding a query string with the wrong assumption turns literal plus signs into spaces, or leaves encoded spaces untouched.
What this assumes, and where it stops
Assumptions
- Text is encoded as UTF-8 before escaping, which is the modern standard.
Limitations
- Cannot tell which parts of a URL you intend as structure and which as data. Encoding a whole URL with component scope will escape the :// and break it.
- The application/x-www-form-urlencoded format encodes spaces as + rather than %20. This tool produces %20 when encoding but accepts + when decoding.
Common questions
What is the difference between encodeURI and encodeURIComponent?
encodeURI preserves the characters that give a URL its structure — the colon, slashes, question mark, ampersands. encodeURIComponent escapes those too. Use the first on a complete URL, the second on a value you are inserting into one. Using the wrong one is the most common URL-encoding bug.
Why is a space sometimes %20 and sometimes +?
Percent-encoding uses %20. HTML form submissions use the application/x-www-form-urlencoded format, which uses + instead. Both appear in query strings; decoders generally accept either.
Sources
Formula and content last reviewed on .
Results are estimates for information only, not professional advice.
Related calculators
Tools people commonly use alongside the url encoder & decoder.