>_ URL ENCODE

⚡ runs locally

URL Parser

URL Encoder and Decoder: A Guide to Percent Encoding

What Is URL Encoding?

URL encoding (also called percent encoding) replaces characters that are not allowed in URLs with a % followed by two hexadecimal digits representing the character's byte value. For example, a space becomes %20, an ampersand becomes %26, and @ becomes %40.

This exists because URLs can only contain a limited set of ASCII characters: letters, digits, and a handful of special characters like -, _, ., and ~. Everything else, including spaces, international characters, and symbols with special URL meaning, must be encoded to be safely transmitted across the internet.

When You Need URL Encoding

Building query strings with user input: If a search term contains spaces or special characters (shoes & boots), the query parameter must be encoded: ?q=shoes%20%26%20boots. Without encoding, the & would be interpreted as a parameter separator.

API requests: When constructing API URLs that include dynamic values (file paths, usernames, filter values), encoding prevents malformed requests. This is especially important when passing JSON, base64, or other structured data as URL parameters.

OAuth and redirect URLs: OAuth flows require a redirect_uri parameter that itself is a URL. That inner URL must be percent-encoded so the outer URL remains valid. Forgetting this step is one of the most common OAuth integration bugs.

Internationalized content: Non-ASCII characters (accented letters, CJK characters, emoji) are encoded as their UTF-8 byte sequences. The character "cafe" with an accent becomes caf%C3%A9.

encodeURIComponent vs encodeURI

JavaScript provides two encoding functions with an important difference:

encodeURIComponent() encodes everything except A-Z a-z 0-9 - _ . ! ~ * ' ( ). Use this for encoding individual parameter values. It encodes characters like /, :, ?, &, and # that have special meaning in URLs.

encodeURI() preserves URL structure characters (:, /, ?, #, &). Use this when encoding a complete URL where you want the structure to remain intact but need to handle special characters in the path or query values.

This tool uses encodeURIComponent for maximum safety, since it is the correct choice for the vast majority of encoding tasks.

The URL Parser

Below the encoder/decoder, you will find a URL parser that breaks any valid URL into its component parts: protocol, host, port, pathname, query parameters, and hash fragment. This is useful for debugging API endpoints, verifying redirect URLs, and understanding complex URLs with multiple query parameters.

Common Encoding Mistakes

Double encoding: Running encodeURIComponent twice turns %20 into %2520. If your URL contains literal % characters where it should not, double encoding is usually the culprit.

Encoding the entire URL: Encoding slashes and colons in the protocol and path makes the URL invalid. Only encode the parts that need it (parameter values, path segments with special characters).

Forgetting + vs %20: In query strings, some systems use + for spaces (HTML form encoding) while others expect %20 (RFC 3986). This tool's decoder handles both, converting + to spaces automatically.

Related Tools

Working with encoded data? The Base64 Encoder handles binary-to-text encoding. The HTML Entity Encoder covers HTML-specific escaping. For testing API endpoints with encoded URLs, try the API Request Tester. For a deeper look at free APIs you can build on, see 30+ Free APIs for Developers in 2026.

Privacy

All encoding and decoding happens entirely in your browser. No data is sent to any server. Your URLs and text never leave your machine.