Web & Encoding
URL Encoding Spaces: %20 vs + Explained
%20 is a percent-encoded space. A plus sign is decoded as a space only in form-style query serialization contexts, not universally across every URL component.
Published
The short answer: %20 and + are not interchangeable everywhere
Percent encoding defines %20 for the space byte. Plus-as-space belongs to form/query serialization rules.
Spaces in URL paths
Use %20 for a space. A literal + in a path can remain a plus depending on the parser and application contract.
Spaces in query/form values
application/x-www-form-urlencoded serialization converts spaces to + and decodes + back to spaces within form-style values.
How to encode a literal plus sign
Use %2B when a plus must survive form-style query decoding as the + character.
%20, + and %2B side by side
| Text | Common decoded value | Context |
|---|---|---|
| %20 | space | Percent encoding in path or query |
| + | space | Form-style query value |
| %2B | + | Literal plus in a form-style query value |
Double encoding: %20 → %2520
Encoding the percent sign in %20 produces %2520. One decode yields %20; a second explicit decode yields the space.
UTF-8 and percent-encoded bytes
Non-ASCII characters are commonly converted to UTF-8 bytes and then percent-encoded byte by byte. Decode at the correct component boundary.
Common mistakes
- Decoding a complete URL when only one component should be decoded.
- Treating + as a space in every URL component.
- Forgetting %2B for a literal plus in form data.
- Repeatedly decoding without knowing the serialization layers.
Try the examples in URL Decoder
The tool exposes raw and decoded values; the guide supplies the path and form-query context.
Try the example
Decode %20 in path and query values
Percent-encoded spaces appear in both components of this URL.
https://example.com/a%20b?q=hello%20worldExpected result: The decoded representation contains spaces while the raw component values remain inspectable.
Try the example
Compare + with %2B in a query
Form-style parsing treats + as a space and %2B as a literal plus.
https://example.com/search?q=hello+world&tag=a%2BbExpected result: The query values expose hello world and a+b under form-style semantics.
Try the example
Inspect two encoding layers
The encoded percent sign reveals a second %20 layer.
hello%2520worldExpected result: One layer is hello%20world; a second explicit layer becomes hello world.
Inspect each component
Decode URL space examples
Compare path, query and double-encoding behavior locally.