URL Encode/Decode

Encode text for safe URL usage by converting special characters to percent-encoded sequences, or decode percent-encoded URLs back to readable text.

Ad Space

How URL Encoding and Decoding Works

URL encoding (also known as percent-encoding) replaces unsafe or reserved characters in URLs with a percent sign (%) followed by two hexadecimal digits representing the character's ASCII value. For example, a space becomes %20, an ampersand becomes %26, and a forward slash becomes %2F. This tool uses the JavaScript encodeURIComponent() function for encoding and decodeURIComponent() for decoding.

Encoding Rules

encodeURIComponent() encodes all characters except: A-Z, a-z, 0-9, hyphen (-), underscore (_), period (.), exclamation mark (!), tilde (~), asterisk (*), single quote ('), and parentheses ( ). Every other character is converted to its UTF-8 byte sequence, with each byte represented as %XX in hexadecimal.

Why URL Encoding Is Necessary

URLs can only contain a limited set of characters defined in RFC 3986. Characters like spaces, ampersands, equals signs, question marks, and hash symbols have special meanings in URLs. If you want to include these characters as data (for example, in a query parameter value), you must encode them to prevent them from being interpreted as URL structure.

Without proper URL encoding, a search query containing an ampersand would break the URL parameter parsing. A filename with spaces would be truncated. A user input containing special characters could lead to broken links, security vulnerabilities, or incorrect data being sent to the server. URL encoding ensures that data is transmitted accurately regardless of its content.

Common Characters and Their Encoded Forms

Here are the most frequently encoded characters: space becomes %20 (or + in form data), ampersand (&) becomes %26, equals (=) becomes %3D, question mark (?) becomes %3F, hash (#) becomes %23, forward slash (/) becomes %2F, plus (+) becomes %2B, at sign (@) becomes %40, and colon (:) becomes %3A. Unicode characters are encoded as multiple %XX sequences representing their UTF-8 bytes.

encodeURIComponent vs. encodeURI

JavaScript provides two encoding functions. encodeURIComponent() encodes everything except unreserved characters, making it suitable for encoding individual URL components like query parameter values. encodeURI() preserves URL structure characters like colons, slashes, and question marks, making it suitable for encoding entire URLs. This tool uses encodeURIComponent() because it is the safer and more commonly needed option.

Double Encoding Issues

A common bug in web applications is double encoding, where an already-encoded string is encoded again. For example, %20 (encoded space) becomes %2520 when double-encoded. This tool can help you detect double encoding by decoding a URL and checking if the result still contains percent-encoded sequences, indicating the original was double-encoded.

Use Cases for URL Encoding

Developers use URL encoding when building URLs with query parameters, when passing data through URL fragments, when creating bookmarkable search result pages, when encoding filenames in download URLs, and when debugging URL-related issues in web applications. It is also essential when constructing OAuth callback URLs and API endpoints that include user-provided data.

Privacy Notice

All encoding and decoding happens entirely in your browser. No data is transmitted to any server.