%5B is the URL-encoded left square bracket ([).
In a URL, %5B stands for the left square bracket ([). Here is when to encode it, what it does in each part of a URL, and what every major language outputs.
Quick facts
| Character | [ |
|---|---|
| Name | Left square bracket |
| Unicode | U+005B |
| UTF-8 bytes | 5B (1 byte) |
| Percent-encoded | %5B |
| Lowercase form | %5b — identical meaning |
| Double-encoded | %255B |
| HTML form encoding | %5B |
| RFC 3986 class | Reserved — general delimiter |
What it means in a URL
Square brackets are gen-delimiters reserved for IPv6 addresses in the host (http://[::1]/). Elsewhere they should be encoded as %5B. PHP and Rails-style array parameters (ids[]=1) are where they appear most.
RFC 3986 class: Reserved — general delimiter. It marks the structure of a URL (scheme, authority, path, query, fragment), so as data it must be encoded.
When to encode it
| Where it appears | What to do |
|---|---|
| Path segment | Encode |
| Query value | Encode |
| Fragment | Encode |
| Form body | Encode |
The mistake to watch for
Sending ids[]=1&ids[]=2 raw: many clients accept it, but strict parsers and some proxies reject unencoded brackets. Encode as ids%5B%5D=1.
What each language produces
Every function in this table encodes it. Output for the single character, UTF-8 input, tested against the real runtimes (see the encoding comparator for your own strings).
| Function | Output | |
|---|---|---|
| JavaScript encodeURIComponent(s) | %5B | encoded |
| JavaScript encodeURI(s) | %5B | encoded |
| JavaScript URLSearchParams | %5B | encoded |
| Python urllib.parse.quote(s) | %5B | encoded |
| Python quote(s, safe="") | %5B | encoded |
| Python urllib.parse.quote_plus(s) | %5B | encoded |
| PHP rawurlencode($s) | %5B | encoded |
| PHP urlencode($s) | %5B | encoded |
| Java URLEncoder.encode(s, UTF_8) | %5B | encoded |
| Go url.QueryEscape(s) | %5B | encoded |
| Go url.PathEscape(s) | %5B | encoded |
| Ruby URI.encode_www_form_component(s) | %5B | encoded |
| Ruby ERB::Util.url_encode(s) | %5B | encoded |
| C# / .NET Uri.EscapeDataString(s) | %5B | encoded |
Decoding it
decodeURIComponent('%5B') returns the left square bracket ([). Python: urllib.parse.unquote('%5B'); PHP: rawurldecode('%5B'). Paste any string into the URL decoder to decode it in your browser.
Common questions.
%5B is the percent-encoded form of the left square bracket ([), whose byte value is 0x5B. Decoding the URL turns it back into the character.
Yes. Hex digits in percent-encoding are case-insensitive, so %5b and %5B mean the same thing. RFC 3986 recommends uppercase, and mixing cases can make caches and analytics count one URL as two.
Use your language’s encoder on the value: encodeURIComponent in JavaScript gives %5B, Python’s quote(s, safe="") gives %5B, PHP’s rawurlencode gives %5B.
More from the toolkit.
About this page. Written and maintained by Sri Murugan Systems, the developer of urlencodedecode.com. Character classes follow RFC 3986 §2; language outputs were generated by running each function in its real runtime.