URL encoding — also called percent-encoding — rewrites characters that are unsafe or reserved in a web address as a percent sign followed by a hexadecimal code, so a space becomes %20 and an ampersand becomes %26. That one rule keeps links from breaking when they contain spaces, symbols or non-English text. A good url encoder decoder does both halves of the job: it escapes text so it is safe to drop into a URL, and it reverses the process so you can read an encoded link back as plain text. This page is a url encoder and url decoder in one, running entirely in your browser. Below is everything you need to understand percent encoding, pick the right function, and avoid the mistakes that silently break tracking links and API calls.
What is URL encoding (percent encoding)?
A URL is only allowed to contain a limited set of characters. The specification that governs this, RFC 3986, divides the character space into groups: a small set of always-safe characters, a set of reserved delimiters that have special meaning, and everything else. When you need to put a character from that “everything else” bucket into a URL — or a reserved character that you want treated as data rather than as a delimiter — you url encode it.
The mechanism is simple. Each byte that needs escaping is written as a % followed by its two-digit hexadecimal value. A space is byte 0x20, so it becomes %20. An ampersand is 0x26, so it becomes %26. This is why the technique is called percent encoding, and why you will sometimes hear it described as url escape — you are escaping the character so the browser and server do not misread it.
Decoding simply reverses the lookup: the decoder scans for every %, reads the two hex digits that follow, and turns them back into the original byte. Because encoding and decoding are exact inverses, a correctly encoded value always round-trips back to the text you started with — which is the quickest way to confirm a link is built right.
Reserved vs unreserved characters
The single most useful thing to internalise is which characters are safe and which are not. Get this right and most encoding decisions become obvious.
Unreserved characters (never encoded)
These are always legal in a URL and should never be escaped: the letters A–Z and a–z, the digits 0–9, and the four marks - (hyphen), _ (underscore), . (period) and ~ (tilde). A correct uri encoder leaves all of these untouched.
Reserved characters (delimiters)
These have structural meaning in a URL: : / ? # [ ] @ ! $ & ' ( ) * + , ; =. They separate the scheme, host, path, query and fragment. Whether you encode them depends entirely on whether you mean them as a delimiter or as literal data — which is exactly the distinction the two JavaScript functions below are built around.
| Character | Encoded | Role in a URL |
|---|---|---|
| space | %20 | Not allowed raw; always encode |
| & | %26 | Separates query parameters |
| ? | %3F | Starts the query string |
| # | %23 | Starts the fragment / anchor |
| / | %2F | Path separator |
| + | %2B | Literal plus (not a space) |
| = | %3D | Separates key and value |
encodeURIComponent vs encodeURI: the key difference
JavaScript ships two encoding functions, and choosing the wrong one is the most common percent-encoding mistake. This tool lets you switch between them, with encodeURIComponent as the default because it is the one you want most of the time.
encodeURIComponent encodes a single component — one query value, one path segment, one piece. It escapes the reserved delimiters & ? / # = : @ + as well as spaces, because inside a single value those characters are data, not structure. This is what you reach for when building a query parameter.
encodeURI encodes a whole URL and deliberately leaves the structural characters alone, so the result is still a usable address. It will encode a space to %20 but it will not touch & ? / # =, because doing so would break the URL into nonsense. Use it only when you have a complete URL that you want to make safe without dismantling it.
| Input | encodeURIComponent | encodeURI |
|---|---|---|
| a b&c | a%20b%26c | a%20b&c |
| ?x=1 | %3Fx%3D1 | ?x=1 |
| path/to | path%2Fto | path/to |
The rule of thumb: encode the value, not the whole link. Build each query value with encodeURIComponent, then join them with the raw & and = delimiters yourself. Reach for encodeURI only in the narrow case where you already hold a finished URL.
When should I URL-encode a query parameter?
Query parameters are where encoding matters most, because their values are user- and data-driven. Encode a parameter value whenever it might contain anything beyond plain letters and digits:
- Search terms: ?q=link building & seo must become ?q=link%20building%20%26%20seo, or the & is read as a new parameter.
- Email addresses: the @ and any + tag need escaping in some contexts.
- Redirect URLs: a URL passed as a value — ?return=https://site.com/a?b=1 — must be fully encoded so its own ? and & do not leak into the outer query.
- Campaign names: a UTM value with spaces breaks analytics unless encoded. Build clean tracking links with the UTM builder, which handles this for you.
Spaces: %20 vs the plus sign
Spaces cause more confusion than any other character. There are two conventions. In a URL path, and whenever you use encodeURIComponent or encodeURI, a space is written as %20. In the application/x-www-form-urlencoded format that HTML forms use for the query string, a space is historically written as +.
Both can be valid, but they are not interchangeable everywhere. A literal + in a value must itself be encoded as %2B, or a server that treats + as a space will corrupt your data — a phone number like +1 555 can arrive as 1 555 with the plus silently turned into a space. For that reason %20 is the safer, more portable choice, and it is what this encode url online tool produces.
UTF-8 percent-encoding and non-ASCII text
URLs were originally limited to ASCII, but the modern web is full of accented letters, emoji and non-Latin scripts. The solution is to encode each character as its UTF-8 bytes, then percent-encode those bytes. A single character can therefore turn into several escapes.
For example, the character é is two bytes in UTF-8 and encodes to %C3%A9. The Hindi word नमस्ते expands to a long run of three-byte escapes. Emoji, which live outside the basic plane, become four-byte sequences. This tool uses the browser’s native UTF-8 handling, so the output matches exactly what servers and other languages expect — no mojibake, no guessing at code pages.
Encoding URLs in JavaScript and Python
This tool mirrors the behaviour of the standard library functions, so you can prototype here and copy the logic into code.
JavaScript
- encodeURIComponent(value) for a single query value or path segment.
- encodeURI(url) for a whole URL.
- Better still, let the platform build the query for you: new URLSearchParams({ q: 'a & b' }).toString() handles escaping safely.
- decodeURIComponent and decodeURI reverse the two encoders.
Python
- urllib.parse.quote(value) is the rough equivalent of encodeURIComponent (note it leaves / alone by default — pass safe='' to encode it too).
- urllib.parse.quote_plus(value) encodes spaces as + for form data.
- urllib.parse.unquote(value) decodes percent-escapes back to text.
Small differences in which characters each function treats as “safe” are why a quick check in a neutral url decode tool is useful before you ship — paste the output of your code here and confirm it round-trips cleanly.
Double encoding: the pitfall that breaks links silently
Double encoding is the classic percent-encoding bug. It happens when you encode a string that is already encoded. Because % is itself a reserved character, encoding %20 again turns the % into %25, giving %2520. The link still looks plausible, but a space now arrives as the literal text %20.
The symptoms are telling: query values show stray %2520 or %253D sequences, redirect URLs land on a page that does not exist, and analytics report campaign names full of %20. The fix is discipline: encode a value exactly once, and if you are unsure whether a string is already encoded, decode it first in this tool. If decoding changes nothing, it was plain text; if it reveals readable characters, it was already encoded and you should not encode it again. The Swap button makes this round-trip easy — decode, inspect, then encode once if needed.
Using percent encoding in APIs and UTM links
Two everyday jobs lean heavily on encoding. The first is calling APIs: path parameters and query strings in REST requests must be encoded so that IDs with slashes, search filters with spaces, or signatures with + and / characters are transmitted intact. An unencoded + in an OAuth signature is a notorious source of “invalid signature” errors.
The second is marketing links. UTM parameters — utm_source, utm_medium, utm_campaign — frequently contain spaces or ampersands, and an unencoded value fractures the tracking in your analytics. Rather than hand-encode each one, use the dedicated UTM builder to assemble correct, encoded campaign URLs, and keep this encoder nearby for the one-off values it does not cover. You will find both, plus the rest of the utilities, on the free SEO tools index.
A worked example, step by step
Suppose you want to link to a search results page for the phrase link building & SEO and anchor it to a specific section. The raw, un-encoded attempt looks like this:
- Naive URL: https://serpbays.com/search?q=link building & SEO#results
This is broken in three places. The spaces are illegal, the & inside the value is read as the start of a second parameter, and the # would normally begin a fragment. The fix is to encode only the value of q with encodeURIComponent, leaving the structural ?, = and # in place:
- Correct URL: https://serpbays.com/search?q=link%20building%20%26%20SEO#results
Notice that the space became %20 and the ampersand inside the value became %26, but the ? that opens the query and the # that opens the fragment were left untouched because they are doing their structural job. Paste the naive version into the tool above in encode mode to watch this happen, then use the Swap button and decode mode to turn it back into readable text.
Common percent-encoding mistakes to avoid
Most encoding bugs come down to a handful of recurring errors. Scan this list before you ship a link or an API call:
- Encoding the whole URL with encodeURIComponent: this escapes the :// and every delimiter, producing a single unusable blob. Encode components, not the full address.
- Forgetting to encode a nested URL: a redirect target passed as a query value must be fully encoded, or its own ? and & hijack the outer query string.
- Treating + as always meaning a space: in a path it is a literal plus; only form-encoded query strings read it as a space. Encode a literal plus as %2B to be safe.
- Double encoding: running an already-encoded string through the encoder again, turning %20 into %2520.
- Encoding unreserved characters needlessly: escaping letters, digits or - _ . ~ is harmless but ugly and can defeat caching and deduplication.
Decoding safely and handling malformed input
Decoding is the reverse of encoding, and it is where most crashes happen. A percent sign must always be followed by exactly two valid hexadecimal digits. If the input contains a lone %, or a truncated escape like %E0%A4 that is missing its final byte, the decode function throws an error rather than returning garbage.
This tool catches those errors and shows a clear, specific message instead of breaking, so you can see exactly where the problem is and fix the input. That makes it safe to paste log excerpts, half-copied URLs or hand-typed escapes without worrying about the page locking up. If a decode fails, check first for a stray % that should have been encoded as %25, which is by far the most common cause.
Privacy: why in-browser encoding matters
This url encoder decoder runs entirely in your browser using JavaScript. Nothing you type or paste is sent to a server, stored or logged — the encoding and decoding happen on your own device. That matters because the strings people encode are often sensitive: internal admin URLs, API endpoints, access tokens embedded in query parameters, signed links and customer data.
Any tool that processes those strings on a remote server is a place your secrets could be retained or exposed. In-browser conversion removes that risk entirely, which is why a privacy-respecting encoder is the safer default. You can work offline, close the tab, and leave no trace behind. Paste a URL into the tool above to encode or decode it in real time, switch functions to see how encodeURIComponent and encodeURI differ, and use Swap to round-trip any value with confidence.