Diagnosing an incomplete percent escape
A percent sign in encoded text must be followed by two hexadecimal digits. This guide shows how to recognize a truncated escape such as %2 at the end of a copied value, and how it differs from a literal percent sign and from a complete UTF-8 sequence.
What a percent escape is
URLs can carry only a limited set of characters directly. Everything else, including spaces, non-ASCII letters and reserved symbols used as data, is written as one or more percent escapes. An escape is a percent sign followed by exactly two hexadecimal digits that give one byte value, as defined in RFC 3986. A space becomes %20, and a slash used as data becomes %2F. The digits may be uppercase or lowercase, so %2f and %2F carry the same byte. Because the format is fixed, a decoder knows exactly how many characters to read after each percent sign. When fewer than two valid hexadecimal digits follow, the escape is malformed, and a strict decoder stops with an error instead of guessing what the sender meant. Percent-encoding applies to bytes, not to characters directly, so a character outside ASCII first becomes its UTF-8 bytes and each byte then gets its own escape. That is why one visible letter can appear as two or three escapes in a long address.
The truncated escape
A copied value such as hello%2 ends in the middle of an escape. After the percent sign there is only one digit, so the byte value is incomplete. The decoding tool reports an invalid percent escape for this input, which is the behavior shown in the first case below the article. The error does not tell you which character was lost. The missing digit could be anything from 0 to F, and %20, %2F and %2C all begin with %2 but mean different characters. Guessing a digit that happens to decode would produce text that looks plausible and is wrong. The sound response is to return to the source and recover the original, whether that is a longer log line, a full address or the unencoded text. A related symptom is a value that ends with a lone percent sign. There the decoder has no digits at all to read, and the error is the same family. Both cases mean the text stopped before the sender finished writing it.
How truncation happens
Incomplete escapes usually come from a cut somewhere between the original text and the place you are reading it. A log viewer may clip long lines at a fixed width. A form field with a maximum length may drop the end of a pasted address. A message formatter may break a line in the middle of a token. A user may select too little when copying. In each case the cut lands at a random place, and a cut inside an escape leaves it incomplete. Looking at the very end of the value is the quickest diagnostic, since the most common cause is a clip at the right edge.
A literal percent sign
Sometimes a percent sign is meant to be data. To write one inside an encoded component, you encode it like any other reserved character, as %25. The value 50% therefore appears as 50%25. Decoding 50%25 returns 50%, which is the second case below the article. A bare percent sign in encoded text is ambiguous, because a decoder will try to read the next two characters as hexadecimal digits. If those characters are not valid digits, the decoder fails. If they happen to be valid, the decoder silently consumes them, and the result is wrong without any error. For that reason, text that is going to be decoded should have every literal percent sign written as %25 beforehand.
A complete multi-byte sequence
Characters outside ASCII are encoded as several bytes in UTF-8, and each byte becomes its own escape. The letter é has the code point U+00E9, and UTF-8 represents it with the two bytes C3 and A9, so its encoded form is %C3%A9. Decoding that string returns é, shown as the third case below the article. Each of the two escapes is complete, and together they form a valid UTF-8 sequence. The euro sign works the same way with three bytes: %E2%82%AC decodes to the euro sign, whose code point is U+20AC. A character with more bytes needs more escapes, and cutting such a string anywhere inside an escape, or between the bytes of one character, breaks the decoding.
Complete escapes can still fail
Having two digits after every percent sign is necessary and not sufficient. The bytes must also form valid UTF-8. A lone %C3 is a complete escape, but the byte C3 announces a two-byte character and nothing follows it, so decoding as UTF-8 fails. Likewise, %FF is a complete escape that never occurs in valid UTF-8 at all. The linked decoder returns the same message for these problems, which reads Invalid percent escape or UTF-8 sequence, so the message alone does not say whether an escape is short or a byte sequence is broken. It does not try to guess another character encoding such as Latin-1, which would turn %E9 into é. Older systems did produce such text, and if you suspect a legacy source, the original encoding needs to be identified separately before the bytes can be interpreted.
Spaces, plus signs and other lookalikes
Several habits blur the picture. In percent-encoded components, a space is %20. Form submissions in the older application/x-www-form-urlencoded style use a plus sign for a space instead, a convention described in the URL Standard maintained by WHATWG, and a plain component decoder does not apply it. A plus sign in a component decodes as a plus sign. Another source of confusion is double encoding, where an already encoded string is encoded again and the percent signs become %25, so %20 turns into %2520. Decoding once then returns %20, not a space. If a decoded result still contains escapes, that is the likely cause, and a second pass may be needed. Do not decode more times than the data was encoded. Reserved characters need care as well. A question mark, ampersand, equals sign and hash mean something to the URL parser when they appear raw, so a value that contains them must have them encoded as %3F, %26, %3D and %23 to survive as data.
Digits that are not hexadecimal
Two characters after the percent sign are required, and both must be hexadecimal digits: 0 to 9 and A to F in either case. A value like %zz has two characters after the percent sign, yet it is malformed, because z is not a hexadecimal digit. So is %2G. A decoder that follows the standard rejects these, while a lenient one might pass them through unchanged. The strict behavior is safer for diagnosis, since a pass-through hides the fact that something was never encoded. Text such as a discount of 20%off in a pasted sentence can trigger exactly this error when it is decoded, because the characters following the percent sign look like a malformed escape. Encoding the percent sign as data first removes the ambiguity.
How two escapes make one letter
The bytes C3 and A9 are not two separate characters. In UTF-8, a byte beginning with the bits 110 starts a two-byte sequence, and the following byte must begin with 10. C3 is 11000011 and A9 is 10101001. Removing the marker bits leaves 00011 and 101001, and joining them gives 00011101001, which is 233 in decimal, or hexadecimal E9. That is the code point U+00E9, the letter é. The same scheme with a three-byte lead, which begins 1110, produces the euro sign from E2 82 AC. Seeing the structure explains why an isolated C3 cannot be decoded and why a cut between the two escapes of one letter fails. The decoder needs the whole sequence, not just complete escapes.
Recovering from a malformed value
When a decode fails, work through a short routine. First, look at the end of the string for a percent sign followed by fewer than two characters. Second, scan the middle for a percent sign followed by characters that are not hexadecimal. Third, if all escapes are well formed, examine the bytes for an incomplete multi-byte character. Throughout, keep the original text unchanged and work on a copy. If the value was cut off, fetch the full one from its source, such as the complete log entry or the original link. If a percent sign was meant as data, correct it to %25 at the source of the text. Replacing the problem by editing digits until the decoder accepts the string only produces output that looks valid and may differ from what was sent.
Reading the three cases together
The three inputs form a small test set. The first, hello%2, fails because the escape is incomplete. The second, 50%25, succeeds and returns a literal percent sign, which shows that a percent sign can appear in a decoded result when it is encoded as data. The third, %C3%A9, succeeds and returns a single accented letter built from two bytes. Together they cover the main outcomes: incomplete, literal and multi-byte. When a decoder reports an error on a real value, try to place the value in one of these categories. An incomplete escape points to truncation. A failure with complete escapes points to invalid bytes. A result that still contains percent signs points to double encoding.
What the tool does and does not check
The decoder verifies the structure of the escapes and the validity of the resulting UTF-8 bytes. It does not check that the decoded text is a well-formed address, that a path exists, or that a server will accept the value. It also does not repair input. Keeping the original string intact is the safest practice during troubleshooting. Work on a copy, record where the value came from, and compare the decoded form with what the sender intended. If an error persists after you recover the full value, examine the surrounding system for a step that alters or clips text, because the decoder itself is behaving consistently.
Reproduce the checks
Truncated escape
Open the Url Encoder Decoder and enter:
- Calculation mode
decode- Text or encoded input
hello%2
Expected rejection:
Invalid percent escapeThe final escape is missing a hexadecimal digit.
Literal percent sign
Open the Url Encoder Decoder and enter:
- Calculation mode
decode- Text or encoded input
50%25
Expected output:
Text
50%The percent character is represented as data.
Complete UTF-8 sequence
Open the Url Encoder Decoder and enter:
- Calculation mode
decode- Text or encoded input
%C3%A9
Expected output:
Text
éThe two bytes encode one non-ASCII character.
References and implementation scope
The examples describe the behavior of the linked Computandum tools. A successful local check does not establish that another application accepts the same format or applies the same limits.
Sources
- Primary definition and convention reference ↗ · 2026-10-08