Skip to main content
Back to tools

URL Encoder

Encode and decode URL components

About URL Encoder

Percent-encodes text with JavaScript's encodeURIComponent and decodes it back with decodeURIComponent, treating non-ASCII characters such as é or emoji as UTF-8. Because URL delimiters like / ? # & and = are escaped too, it suits a single component, such as a query value, a redirect_uri parameter or a path segment, rather than a whole URL.

Category: API.

Frequently asked questions

When do I need to URL-encode?

▾

Whenever a value you put into a URL contains spaces, non-ASCII letters or characters with a special role, such as & = + # ? or /. Encoding them as %XX sequences keeps them as literal data instead of being read as part of the URL structure.

What's the difference between encodeURI and encodeURIComponent?

▾

encodeURI leaves characters that structure a URL, such as / ? # & and =, untouched, so it suits a complete URL. encodeURIComponent, which this tool uses, escapes them as well and keeps only letters, digits and - _ . ! ~ * ' ( ), so it suits a single query value or path segment.

Why does a space become %20 and not +?

▾

Encoding here always produces %20, the RFC 3986 form that works anywhere in a URL. The + form only means a space in application/x-www-form-urlencoded query strings, and decoding leaves + unchanged, so replace + with spaces first when decoding form data.

Why do I get "Invalid encoded URL string" when decoding?

▾

Decoding fails when a % isn't followed by two hex digits, as in 100%, or when the bytes don't form valid UTF-8, such as the Latin-1 escape %E9. Encode a literal percent sign as %25.

Related tools