Finding a double-encoded percent escape
The text %2520 looks like one escape but contains two layers: it decodes to %20 after one pass and to a space after a second. This guide traces that path and explains how to decide where to stop.
What percent encoding does
Percent encoding represents a character as a percent sign followed by two hexadecimal digits, which stand for a byte of the UTF-8 form of the character. A space is the byte 20, so it becomes %20. An ampersand is 26, so it becomes %26. The percent sign itself is the byte 25, so a literal percent sign becomes %25. RFC 3986 defines the scheme for URIs. Decoding reverses it: each %XX is replaced by the byte it names, and the bytes are read as UTF-8 text. Because the percent sign is also the escape character, any text that already contains one needs it escaped when it is encoded again, and that is the source of double encoding.
Tracing red%2520blue
The first worked case starts with red%2520blue. The decoder reads %25 as a percent sign and leaves the digits 20 untouched, producing red%20blue. The result contains a percent sign followed by 20, which looks like another escape, but the first pass does not look again at what it just produced. A second decoding pass reads %20 as a space and gives red blue. Written as a chain, the text goes from red%2520blue to red%20blue to red blue. Keeping each intermediate string in view is the way to know which stage you are at and which stage the receiving system expects.
How double encoding happens
It usually starts with a value that was encoded once and then passed through code that encodes it again. A web form value is encoded by a browser, a framework decodes it but a library further on encodes the string for a redirect, and the result is encoded twice. Nested links produce it by design: a login page may carry a return address as a query parameter, such as the address https://example.com/a b encoded once to https%3A%2F%2Fexample.com%2Fa%20b. If that whole link is placed inside another URL, its percent signs are escaped again to %25 and the text becomes harder to read. Each layer of wrapping adds one level of encoding.
Recreating the outer layer
The third worked case encodes red%20blue and obtains red%2520blue. This confirms the logic from the other side: the percent sign in the input is data, so the encoder turns it into %25, and the digits that follow stay as they are. The pair of operations shows that decoding once undoes one encoding. If the original value had a real percent sign in it, such as the text 50% off, a correct encoding is 50%25%20off. Decoding it once returns the original, and decoding it again would try to read a percent sign followed by a space, which is not a valid escape and is rejected by a strict decoder.
Why a readable result is not proof
After the second pass, red blue is easy to read, and it is tempting to conclude that two passes were right. That is a weak test, because some inputs are valid at several layers. A file name such as 100%25 pure could be meant as a literal name containing percent signs, and decoding it further would damage it. A value after one pass may be correct as data even when it still contains escapes, for example a stored template or a URL kept inside a database field. The correct number of passes is set by how the value was built, and that is a property of the system that wrote it, not of the text.
Follow the convention of the receiving field
Decide the correct layer by asking where the string is going. A server that already decodes query parameters expects one layer of encoding in the request and delivers the decoded value to the application. If the application then decodes again, text that legitimately contains a percent sign may be changed or rejected. Conversely, a field that expects encoded text and receives decoded text may break on spaces or ampersands. Check the documentation of the framework, the API or the database column involved, and compare the intermediate strings, not the final result, when two systems disagree about what a value means. A request log, a browser developer tools network panel or a debugging print placed before and after each component usually shows the exact layer where the text changed. Once you know that layer, you know which component to fix.
Security reasons to avoid repeated decoding
Decoding more than once is a known source of security problems. A filter that checks a path for the sequence ../ and then decodes it again can be bypassed by sending %252e%252e%252f, which survives the first check as harmless text and turns into ../ after the second pass. OWASP describes this as a double-encoding attack. The safe pattern is to decode exactly once at the boundary, validate the decoded value, and treat it as data from then on. If a value looks as though it needs a second decode, investigate why it was encoded twice, and fix the producer instead of adding another pass.
Strict decoding and invalid escapes
The component decoder here is strict about percent escapes. A percent sign that is not followed by two hexadecimal digits, such as the trailing percent in 100%, is not a valid escape. The decoded bytes must also form valid UTF-8, so an input like %C3 alone, which is the first half of a two-byte character, is rejected in the same way as an incomplete hexadecimal sequence. A lenient decoder might pass such text through or substitute a replacement character and hide the fault. Rejecting the input keeps the problem visible. When a rejection occurs, look for a literal percent sign that was never encoded or for text cut in the middle of a character.
A routine for tracing an unknown value
Keep the original string and decode one pass at a time, writing each result next to the previous one. Stop as soon as the string stops containing escapes that the receiving field would treat as data, or when the next pass would change a character that is supposed to be literal. Compare against a second source if you have one, such as a log of the request before it reached the application. Note how many passes were needed and which component added each layer. The decoder handles one layer per operation by design, which makes the stages visible instead of collapsing them into one opaque step.
Reproduce the checks
First decoding pass
Open the Url Encoder Decoder and enter:
- Calculation mode
decode- Text or encoded input
red%2520blue
Expected output:
Text
red%20blueThe percent sign has been decoded once.
Second decoding pass
Open the Url Encoder Decoder and enter:
- Calculation mode
decode- Text or encoded input
red%20blue
Expected output:
Text
red blueThis is a separate operation on the intermediate output.
Recreate the outer layer
Open the Url Encoder Decoder and enter:
- Calculation mode
encode- Text or encoded input
red%20blue
Expected output:
Text
red%2520blueThe percent character is encoded when it is source data.
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