URL Encoder and Decoder
Paste text or a URL and see the encoded or decoded version right away, using the percent-encoding (%20, %C3%A7) that browsers use.
Result
https://exemplo.com.br/busca?q=ação rápida&cidade=São Paulo
What URL encoding is
A URL can only contain a small set of ASCII characters. Spaces, accents and symbols such as & and # become a % followed by two hexadecimal digits for each UTF-8 byte. The letter "ç" becomes %C3%A7 and a space becomes %20.
That is why an address copied from a browser is often full of % signs. Decoding shows the original text, and encoding prepares a value to go into a URL safely.
Which format to pick
- Component (encodeURIComponent): for a single value, such as the content of a parameter. It encodes / ? & = # and anything else that could break the URL.
- Full URL (encodeURI): for a whole address. It leaves / ? & = # and : as they are and encodes only spaces, accents and other invalid characters.
- Form: the same as the component format, except that a space becomes +. This is the format of HTML forms and URLSearchParams.
Common mistakes
- Encoding a whole URL as a component, which turns https:// into https%3A%2F%2F and breaks the link.
- Encoding twice. The % becomes %25 and %20 turns into %2520. If %25 shows up in the result, the text was already encoded.
- Decoding a form value as a component. The + stays a + instead of becoming a space.
URL Encoder and Decoder FAQ
The difference between formats, spaces and decoding errors.
encodeURI keeps the characters that structure a URL, such as / ? & = and #. encodeURIComponent encodes all of them, which is what you want for parameter values. For a complete URL, use encodeURI.
Both show up. %20 works anywhere in a URL. + works only in forms and the query string, in the application/x-www-form-urlencoded format. When in doubt, use %20.
A % must be followed by two hexadecimal digits, and the bytes in a sequence must form valid UTF-8. When that fails, the built-in decoder throws an error. Here the part stays as it is and appears in the list of problems.
It means encoding text that was already encoded: %20 becomes %2520. If the result contains %25, decode once and check whether it is right now.