URL encoding — formally called percent encoding — is defined by RFC 3986, the specification that governs the syntax of Uniform Resource Identifiers. A URL can only safely contain a limited set of characters: letters, digits, and a handful of unreserved symbols like hyphens, dots, tildes, and underscores. Any other character — including spaces, ampersands, equal signs, non-ASCII letters, and most punctuation — must be encoded as a percent sign followed by two hexadecimal digits representing the character's byte value in UTF-8. A space becomes %20, an ampersand becomes %26, and the at symbol becomes %40.
JavaScript provides two native functions for URL encoding with importantly different behaviors. encodeURI() is designed for encoding a complete URL — it preserves characters that have structural meaning in a URL, such as /, ?, #, &, and =. encodeURIComponent() encodes everything including those structural characters, making it the right choice for encoding individual query parameter values. Use encodeURIComponent() for query string values and path segments that may contain special characters.
One subtle distinction worth knowing: HTML form submissions via the GET method use application/x-www-form-urlencoded format, which encodes spaces as + rather than %20. Standard percent encoding always uses %20 for spaces. Both decode back to a space, but they are not interchangeable — a + in a URL path means a literal plus sign, not a space.
A developer builds a product search feature. The user types best coffee & tea shops near me into the search box. The JavaScript encodeURIComponent() function transforms this into best%20coffee%20%26%20tea%20shops%20near%20me. Each space becomes %20 and the ampersand becomes %26. The resulting URL is a valid, unambiguous string that any server or browser can parse.
Without URL encoding, the ampersand would break the query string parser. The server would see two parameters — q=best coffee and tea shops near me — instead of one intact search phrase. URL encoding ensures the entire value is transmitted as a single parameter.
International characters follow the same principle. The Japanese characters for Tokyo (東京) encode as %E6%9D%B1%E4%BA%AC — each UTF-8 byte pair percent-encoded. Modern browsers display the decoded version in the address bar for readability, but the actual network request always uses the encoded form. This is why pasting a URL from a browser address bar sometimes reveals encoded sequences that were not visible when you copied it.
Reserved vs unreserved characters: RFC 3986 divides URL characters into two groups. Reserved characters (/ ? # [ ] @ ! $ & ' ( ) * + , ; =) have structural meaning in URLs and must only be encoded when they appear inside a parameter value. Unreserved characters (letters, digits, - _ . ~) never need encoding and should be left as-is.
Double encoding is one of the most common URL handling mistakes. If a URL is encoded twice — for example, %20 becomes %2520 on the second pass (the % sign itself gets encoded) — then decoding once produces %20, not a space. The server or client must decode again to recover the original value. Always encode exactly once and decode exactly once.
Path encoding vs query string encoding: the path segment of a URL (/products/my item) and the query string (?name=my item) have slightly different encoding rules. Both need spaces encoded, but path segments must not have / encoded (it separates path levels), while query strings must encode & and = inside values. Use encodeURIComponent() for individual values in either context.
This url encoder decoder converts text to percent-encoded format and back in real time using native encodeURIComponent and decodeURIComponent. Use Component mode for individual query parameter values, or Full URL mode to encode a complete URL while preserving its structure. All processing runs in your browser — no data is sent to any server.
URL encoding (also called percent encoding) converts characters that are not allowed in a URL into a safe format. Each unsafe character is replaced with a % followed by two hexadecimal digits representing the character's UTF-8 byte value. For example, a space becomes %20 and & becomes %26.
The % characters you see in URLs are percent-encoded characters. URLs can only contain a limited set of ASCII characters safely. Any character outside that set — including spaces, non-ASCII letters, and special symbols — must be url encode'd using the %XX format so the URL is transmitted correctly by browsers and servers.
encodeURI is designed for encoding a full URL — it preserves characters like :, /, ?, &, = that have structural meaning in a URL. encodeURIComponent is designed for encoding a single query parameter value — it encodes those structural characters too, so the value cannot be confused for URL structure. Use encodeURIComponent (Component mode) for individual values.
Switch to Decode mode and paste your percent-encoded string. The tool uses the native decodeURIComponent function to decode it instantly in your browser. This converts %20 back to space, %26 back to &, and so on. Your data never leaves your device.
No. URL encoding and Base64 encoding solve different problems. URL encoding replaces unsafe URL characters with %XX sequences and is used to safely transmit data in URLs. Base64 encoding converts binary data to a printable ASCII string and is used for transmitting binary data over text-based protocols. They are not interchangeable.