Paste a value with an ampersand into a query string and the URL quietly changes meaning: ?q=fish & chips is not one search term, it is a parameter q set to "fish " plus a stray second parameter called " chips". Nothing errors. The address just lies. The fix is percent-encoding, and the real question is which characters need it, because the answer depends on where in the URL the character sits.
This guide walks the character groups one at a time, with a before and after example for each, using the free URL Encoder/Decoder on Ovatly. The organising idea is simple: some characters are structure, some are data, and trouble starts when data wears a structural costume.
Contents
- Quick answer
- The two jobs a character can do
- The character groups, one by one
- How to encode a value, step by step
- Worked example: one search phrase, seven fixes
- Limitations and honest warnings
- Common mistakes
- FAQs
- Conclusion
Quick answer
Inside a single value, such as a search term or a redirect target, encode everything a URL cannot carry raw: spaces (%20), & (%26), = (%3D), ? (%3F), # (%23), / (%2F), % itself (%25), and every non-ASCII character, which is encoded as its UTF-8 bytes. In a whole address, those same marks are often legal structure: the ? that starts the query, the & between parameters, the / between path segments. That split is why the URL Encoder/Decoder has two modes: Component mode for one value, Full URL mode for a whole address.
The two jobs a character can do
A URL is a small grammar. The : and // introduce the host, / separates path segments, ? opens the query string, & separates parameters, = joins a name to its value, and # starts the fragment. When those characters appear in those positions, they are structure and must stay raw, or the address falls apart.
Everywhere else, the same characters are data, and data must not be mistaken for structure. A / inside a file name, a ? inside a question used as a search term, an & inside a product name: left raw, each one is read as grammar and the URL is parsed into something its author never meant. Percent-encoding is how data resigns from grammar duty. The character is replaced by a % followed by two hexadecimal digits, and every reader downstream knows to treat it as plain text.
A small set of characters never has this problem. Letters, digits and the unreserved marks -, ., _ and ~ are safe anywhere, raw, in any position. Everything in the next section is safe only in its structural seat, or not safe raw at all.
The character groups, one by one
Space. A URL cannot contain a literal space. As a value, my file name becomes my%20file%20name. Form submissions write a space as + inside query strings, which is why you see both forms in the wild; this tool uses %20, which is valid everywhere in a URL, to avoid ambiguity.
Ampersand &. The parameter separator. Inside a value it must be %26: fish & chips becomes fish%20%26%20chips. Left raw, everything after it is read as a new parameter.
Equals sign =. The name-value joiner. Inside a value it becomes %3D, so a=b encodes to a%3Db. Left raw inside a value, it can split that value at the wrong place when the query is parsed.
Question mark ?. Opens the query string, so only the first one is structure. A question used as data, what?, encodes to what%3F. A second raw ? inside a value confuses parsers about where the query really started.
Hash #. Starts the fragment, the part of the URL that is never sent to the server. section #3 becomes section%20%233. Left raw, everything after it is treated as a fragment and silently dropped from the request.
Slash /. Separates path segments. Inside a single value, such as a file path or a category name being passed as a parameter, it becomes %2F: docs/guide encodes to docs%2Fguide. Left raw, one value turns into two path segments.
Percent sign %. The escape character itself, so a literal one must be escaped as %25: 100% sure becomes 100%25%20sure. A raw % followed by two hex digits will be decoded as somebody else's encoded character, and a raw % followed by anything else produces a decode error.
Non-ASCII characters. Letters outside plain ASCII, such as é, are encoded as their UTF-8 bytes, one percent-encoded byte per byte. café menu becomes caf%C3%A9%20menu: the é alone produces %C3%A9. This is also why encoded text gets longer, three characters for each unsafe character and more for non-ASCII.
How to encode a value, step by step
- Open the URL Encoder/Decoder.
- Choose Component mode for a single value going into a query string, or Full URL mode for a whole address.
- Paste your text or URL.
- Press Encode.
- Copy the result. If you ever feed the tool something invalid to decode, like a stray
%or an incomplete%2at the end, it shows a clear error instead of returning garbage.
Worked example: one search phrase, seven fixes
Take a realistic search phrase that trips over almost every group at once: café menu: fish & chips 100%. Run it through Component mode and each character does its duty:
café menu: fish & chips 100%
caf%C3%A9%20menu%3A%20fish%20%26%20chips%20100%25
Read it piece by piece. The é became %C3%A9, its two UTF-8 bytes. Each space became %20. The colon became %3A, because a raw colon inside a value invites misparsing. The & became %26, so the phrase stays one parameter instead of splitting in two. The % became %25, so the 100% survives as data rather than pretending to start an escape sequence. The letters and digits passed through untouched.
Now contrast Full URL mode on a whole address: https://example.com/a b?q=x y becomes https://example.com/a%20b?q=x%20y. The spaces are encoded, but the :, the //, the ? and the = all stay raw, because in a full address they are structure and the address would break without them. Same tool, same character, opposite treatment, decided entirely by position.
Limitations and honest warnings
Encoding fixes characters, not addresses. It will not repair a wrong domain, a dead path or a mistyped parameter name, and it cannot tell you whether a value was supposed to be encoded in the first place. That judgement stays with whoever builds the URL.
Percent-encoding is not encryption. Anyone who sees the encoded string can decode it with this same tool, so an encoded password or token is exactly as exposed as the plain text. Encode for transport, never for secrecy.
Decoding has a hard edge worth knowing: a stray % or a truncated sequence like %2 at the end is invalid input, and the tool answers with a clear error rather than a best guess. If a decode fails, the string you were handed was probably copied incompletely.
Common mistakes
- Encoding a whole URL in Component mode. The structure gets encoded too,
https:turns intohttps%3A, and the address stops working. Whole addresses belong in Full URL mode. - Leaving
&raw inside a value. The value splits into two parameters and the second half vanishes into a parameter nobody reads. - Leaving
%raw because it "looks fine". A literal percent must be%25. Raw, it either decodes into a different character or makes the string invalid. - Assuming
+and%20are interchangeable everywhere. The+convention belongs to form-encoded query strings. In a path segment, a+is just a plus sign. - Encoding some occurrences by hand and missing others. Encode the whole value in one pass with the tool, not character by character from memory.
FAQs
Which characters never need encoding in a URL?
Letters, digits and the unreserved marks - . _ ~ are safe anywhere in a URL. Everything else either has a structural job or needs percent-encoding, depending on where it sits.
Why does & need encoding inside a value but not between parameters?
Between parameters, & is structure: it separates one parameter from the next. Inside a value it must be %26, or the reader of the URL will treat everything after it as a new parameter.
Is a space written as %20 or as +?
In query strings produced by form submissions, + means a space. This tool uses %20, which is valid everywhere in a URL, to avoid ambiguity.
What happens to non-ASCII characters like é?
They are encoded as their UTF-8 bytes, one percent-encoded byte at a time. The é in café becomes %C3%A9, so café menu encodes to caf%C3%A9%20menu.
Does percent-encoding hide or protect the text? No. Encoding is not encryption. Anyone can decode a percent-encoded string with the same tool, so never treat an encoded value as a secret.
Conclusion
The rule to carry away is positional: a character that is structure in its proper seat must be percent-encoded everywhere else, and %, spaces and non-ASCII characters must be encoded in every position. The URL Encoder/Decoder makes the call for you, as long as you pick the mode that matches what you are pasting, one value or a whole address. The failure that follows from encoding a value twice, and how to undo it, is covered in Double Encoding: How It Happens and How to Fix It. For more tools like these, see the Developer Tools guide archive.