Query-value boundary lab · Updated November 22, 2026
Encode a Question Mark in a URL Query Value
The first question mark starts the query; a question mark inside a value is data and should be encoded as %3F. Keeping those two roles separate prevents a value from being mistaken for a second query boundary.
Boundary or data
| Wire form | Parsed result | Observed boundary |
|---|---|---|
/search?q=next?page=2 | One query value containing a second ? in common parsers | The first ? starts the query; later ones are value data. |
/search?q=next%3Fpage%3D2 | next?page=2 | The inner question mark and equals sign are explicit data. |
/search?q=a%3Fb&page=2 | q=a?b, page=2 | & still separates the outer pairs. |
Measured output
Run date: November 22, 2026. Node.js v24.19.0: encodeURIComponent("next?page=2") = next%3Fpage%3D2. PHP 8.5.12: rawurlencode("next?page=2") = next%3Fpage%3D2.
Input: next?page=2 | URLSearchParams wire value: next%3Fpage%3D2 | Decoded: next?page=2
Download the reproducible fixture CSV
Common failure
Do not split an entire URL on every question mark. Parse the first boundary, then encode question marks that belong to a component value.
FAQ
Is a second question mark always a new query?
No. The first one establishes the query; later question marks are normally part of the value, although application-specific parsers can impose different rules.
Does encoding the question mark change the decoded value?
No. It makes the component boundary unambiguous on the wire; decoding returns the original character.
For equals and ampersand boundaries, see equals in query values and ampersands in query values.