What is URL Encoding?
URL encoding, formally known as percent-encoding, is a mechanism defined in RFC 3986 for representing characters in a Uniform Resource Identifier (URI) that would otherwise be unsafe or ambiguous. Because URLs can only be transmitted using the ASCII character set, any character outside the unreserved set must be converted into a percent sign (%) followed by two hexadecimal digits representing its byte value.
For example, the space character (ASCII 32) is encoded as %20, the ampersand as %26, and the equals sign as %3D. Non-ASCII characters like Unicode text or emoji are first encoded as UTF-8 bytes, and then each byte is percent-encoded individually. This is why a single emoji can expand to 12 or more characters in an encoded URL.
Why URLs Need Encoding
URLs have a strict syntax where certain characters carry structural meaning. The question mark (?) begins a query string, the ampersand (&) separates parameters, the hash (#) marks a fragment, and the forward slash (/) delimits path segments. If your data happens to contain any of these reserved characters, the browser or server will misinterpret the URL structure.
Consider a search query like fish & chips. Without encoding, a URL like ?q=fish & chips would break: the browser would treat & as a parameter separator, reading q=fish as one parameter and chips as the start of another. The correct encoding is ?q=fish%20%26%20chips, which preserves the intended meaning.
Encoding is also essential for internationalized URLs. Domain names use Punycode, but path segments and query strings rely on percent-encoding to include characters from any writing system.
encodeURIComponent vs. encodeURI in JavaScript
JavaScript provides two built-in functions for URL encoding, and choosing the wrong one is a common source of bugs:
encodeURIComponent()encodes a single component — such as a query parameter value or a path segment. It encodes almost everything except letters, digits, and- _ . ! ~ * ' ( ). This is the function you want most of the time.encodeURI()encodes a complete URI but leaves structural characters intact:: / ? # [ ] @ ! $ & ' ( ) * + , ; =. Use this only when you have a full URL that just needs non-ASCII characters encoded.
A practical rule: if you are building a query string by hand, always use encodeURIComponent() on each key and value. If you use encodeURI() on a value that contains & or =, those characters will pass through unencoded and corrupt your query string.
Common Encoded Characters
Here are the most frequently encountered URL-encoded characters:
%20— space (also represented as+in form data)%26— ampersand (&)%3D— equals sign (=)%3F— question mark (?)%23— hash (#)%2F— forward slash (/)%25— percent sign (%) — encoding the encoder itself%40— at sign (@)
How to Use This Tool
- Paste or type your text into the input field.
- Choose Component mode (uses
encodeURIComponent) for encoding individual values, or Full URL mode (usesencodeURI) for complete URLs. - Click Encode to percent-encode your input, or Decode to convert percent-encoded text back to readable form.
- If you paste a full URL, the tool automatically breaks it down into protocol, host, path, query parameters, and fragment.
- Copy the result with one click, or share the URL directly — your input is preserved in the address bar.
Frequently Asked Questions
What is URL encoding?
URL encoding (percent-encoding) replaces unsafe characters in a URL with a % followed by two hex digits. It is defined in RFC 3986 and ensures URLs are transmitted correctly, since URLs may only contain a limited subset of ASCII characters.
Why do URLs need to be encoded?
Certain characters like &, =, ?, and # have special meaning in URL syntax. If your data contains these characters, they must be encoded to prevent the browser or server from misinterpreting the URL structure.
What's the difference between encodeURI and encodeURIComponent?
encodeURI() encodes a full URL but leaves structural characters like /, ?, and & untouched. encodeURIComponent() encodes everything except unreserved characters, making it the right choice for encoding individual query parameter values or path segments.
What is percent-encoding?
Percent-encoding is the official name for URL encoding per RFC 3986. Each character is represented as a percent sign followed by its two-digit hex ASCII value — for example, a space becomes %20 (hex 20 = decimal 32).
Which characters need to be URL encoded?
Reserved characters (: / ? # [ ] @ ! $ & ' ( ) * + , ; =), spaces, and all non-ASCII characters (Unicode letters, emoji) must be encoded. Unreserved characters — A-Z, a-z, 0-9, hyphen, underscore, period, and tilde — are safe without encoding.
Is URL encoding the same as HTML encoding?
No. URL encoding uses %XX sequences for safe URL transmission. HTML encoding uses character entities like & and < to safely display special characters in HTML markup. They solve different problems and are not interchangeable.
What does %20 mean in a URL?
%20 is the percent-encoded form of the space character (hex 20 = decimal 32 in ASCII). In HTML form submissions using application/x-www-form-urlencoded, you may also see + used for spaces, but %20 is the standard encoding per RFC 3986.