URL component encoding
Use the URL Encode / Decode to percent-encode URL components, decode escaped text or convert query form values.
How the calculation works
Component mode uses UTF-8 percent encoding for reserved characters. Form mode also represents spaces with plus signs.
Query form values
Encode or decode spaces and plus signs correctly.
For a URL parameter, encode the value before assembling the query. Encoding a complete URL as one component will also escape punctuation such as the scheme separator and slashes.
Worked example
Example inputs include Input Hello, world! 👋. The result is Hello%2C%20world!%20%F0%9F%91%8B.
How to read the result
A plus sign remains literal when decoding a URL component. Use form decoding for query values whose spaces were encoded as plus signs.
Encode URL pieces before building a link
Use component encoding for path segments and query values that contain spaces or reserved punctuation. If you encode a whole URL as one value, you also escape the punctuation that gives it structure. Form encoding has its own convention for spaces. Match the decoding mode to how the string was produced, especially when it includes a literal plus sign.
Identify what your string represents
A URL contains structural punctuation and individual pieces of data. Preserve the punctuation that separates the scheme, host, path and query while escaping user-supplied pieces. In a query, encode each value independently. When troubleshooting an escaped value, decode it once and inspect the result before deciding whether any remaining percent sequences represent another layer of encoding.
Encode values before assembling the query
Preserve the punctuation that belongs to the whole link. Encode a path segment or query value separately so reserved characters in the input are represented as data. A literal plus sign in a form query value is encoded as %2B.
Match decoding to the source. Form encoding uses a plus sign for spaces, while component encoding uses %20. When there are multiple layers of escaping, decode one layer at a time and inspect the result.
Common questions
In form encoding, a raw plus sign represents a space. A literal plus sign must be written as %2B.
It is the percent encoding for a space byte. Component encoding uses it for spaces.
Encode it as %2B so form decoding preserves it as plus instead of treating it as a space.
Yes. The encoder represents their UTF-8 bytes with percent escapes.
Decoding reports an error. Check that each percent sign in the encoded input is followed by two hexadecimal digits.