URL Encode & Decode

Encode special characters for safe URL usage or decode percent-encoded strings back to readable text.

πŸ“ Input

πŸ“€ Output

What Is URL Encoding?

URL encoding, also known as percent-encoding, is a mechanism for converting characters that are not allowed in a URL into a format that can be transmitted safely over the internet. It replaces unsafe characters with a percent sign (%) followed by two hexadecimal digits representing the character's ASCII or UTF-8 byte value. For example, a space becomes %20, and an ampersand (&) becomes %26.

URLs can only contain a limited set of characters from the ASCII character set. Characters like spaces, quotes, angle brackets, and non-ASCII characters (such as accented letters, Chinese characters, or emoji) must be percent-encoded to create a valid, functional URL. This encoding is defined in RFC 3986 and is essential for web communication.

encodeURIComponent vs. encodeURI

JavaScript provides two built-in functions for URL encoding, and choosing the right one matters. encodeURIComponent() encodes all special characters except - _ . ! ~ * ' ( ), making it ideal for encoding individual query parameter values, path segments, or any piece of data that will be inserted into a URL. encodeURI() is less aggressive β€” it preserves characters that are valid in a complete URL (like :, /, ?, #, and &), making it suitable for encoding an entire URL where you want to keep the structure intact.

When to Use URL Encoding

You should URL-encode data whenever you construct URLs dynamically in your application, especially query string parameters that might contain user input, spaces, or special characters. Common scenarios include building search URLs, constructing API requests with parameters, creating shareable links with embedded data, and handling form submissions with the GET method. Failing to properly encode URLs can lead to broken links, security vulnerabilities (like injection attacks), and data corruption.

Frequently Asked Questions

Why do spaces sometimes appear as %20 and sometimes as +?
The %20 encoding follows RFC 3986 (standard URL encoding), while the + sign for spaces comes from the older application/x-www-form-urlencoded format used by HTML forms. Both are valid, but %20 is the modern standard. This tool uses %20 for consistency.
Should I encode the entire URL or just the parameters?
In most cases, you should only encode individual parameter values using encodeURIComponent, not the entire URL. Encoding the full URL would break the protocol (://), path separators (/), and query delimiters (? and &).
Is URL encoding the same as HTML encoding?
No. URL encoding (percent-encoding) is for making text safe in URLs. HTML encoding converts characters like < and & into HTML entities for safe display in web pages. They serve different purposes and use different formats.
Can URL encoding handle non-English characters?
Yes. Non-ASCII characters are first converted to their UTF-8 byte sequence, and then each byte is percent-encoded. For example, the Chinese character "δΈ­" becomes %E4%B8%AD. This tool fully supports all Unicode characters.
Copied to clipboard!