URL encode, decode & parse
Encode a value for a query string, decode a messy link, or paste a full URL to see its parts and parameters.
Query parameters
| Name | Value |
|---|
Why URLs need encoding
A URL may only contain a small set of characters. Spaces, accented letters, and symbols such as &, = and # have special meaning or are not allowed, so they are replaced with a percent sign and their UTF-8 bytes in hex. A value like cafรฉ & crรจme becomes caf%C3%A9%20%26%20cr%C3%A8me.
Encoding the wrong thing is a common bug: encode each parameter value separately, not the whole URL, or the & and = that separate parameters get escaped too.
Frequently asked questions
What is the difference between encodeURI and encodeURIComponent?
encodeURIComponent encodes everything except letters, digits and - _ . ! ~ * ' ( ), so it is right for a single value such as a query parameter. encodeURI leaves : / ? # & = alone, so it is right for a whole URL.
Why does a space become %20 or a plus sign?
%20 is the standard percent-encoding of a space. + means a space only inside application/x-www-form-urlencoded form data and query strings. The decoder here treats both as a space.
How do I encode a URL in Java?
URLEncoder.encode(value, StandardCharsets.UTF_8) encodes form-style (space becomes +). For a path segment, use UriUtils.encodePathSegment from Spring, or replace + with %20.
What does "Malformed percent-encoding" mean?
A % must be followed by exactly two hex digits. A stray % in the input, such as 100% sure, is not valid.