Query-value boundary lab · Updated November 19, 2026
Encode a Colon in a URL Query Value
A colon in a query value is data; it is not the URL scheme separator once it is after the question mark. Encode it as %3A when the receiver must preserve it literally.
Context changes the meaning
| Location | Example | Meaning |
|---|---|---|
| Scheme | https: | Separates a URL scheme from the rest of the URL. |
| Authority port | example.test:8443 | Separates a host from its port. |
| Query value | next=https%3A%2F%2Fapi.test | Represents a literal colon in data after decoding. |
Measured output
Run date: November 19, 2026. Node.js v24.19.0: encodeURIComponent("https://api.example.test:8443/v1") = https%3A%2F%2Fapi.example.test%3A8443%2Fv1. PHP 8.5.12: rawurlencode returns the same percent escapes.
Input: https://api.example.test:8443/v1 | Query wire value: https%3A%2F%2Fapi.example.test%3A8443%2Fv1 | Decoded: https://api.example.test:8443/v1
Download the reproducible fixture CSV
Common failure
Do not encode the whole outer URL when only the query value is data. Encode the component, then let the outer URL keep its own ? and & structure.
FAQ
Should every colon be encoded?
No. Preserve syntax delimiters in the URL structure and encode colons that belong to a value.
Does percent-encoding change the decoded value?
After correct decoding, the value is still the same colon character; encoding only changes its wire representation.
For nested URLs, see nested URL encoding. For query arrays, see Query Parameters.