What is URL Encoding?
URL encoding, also known as percent-encoding, is the process of converting characters into a format that can be safely transmitted over the internet as part of a URL. URLs are restricted to a specific subset of ASCII characters. Special characters — such as spaces, ampersands, equals signs, slashes, and non-ASCII Unicode characters — must be encoded before they can be included in a URL safely.
The encoding works by replacing the unsafe character with a percent sign (%) followed by two hexadecimal digits representing the ASCII or UTF-8 byte value of the character. For example, a space character ( ) becomes %20, an ampersand (&) becomes %26, and a forward slash (/) becomes %2F.
URL encoding was standardised by the Internet Engineering Task Force (IETF) in RFC 3986, which defines the syntax for Uniform Resource Identifiers (URIs). Following this standard ensures that URLs are universally understood by browsers, servers, APIs, and other HTTP clients regardless of the operating system or programming language involved.
There are two common types: URL encoding (for query strings, where space becomes +) and URI component encoding (more strict, where space becomes %20). Our tool uses PHP's urlencode() function, which follows the application/x-www-form-urlencoded standard commonly used in web forms and APIs.
How to Use This URL Encoder
- Paste your input: In the left text area, type or paste the string, URL component, or query parameter value that you need to encode.
- Click "Encode URL": The tool will instantly process your input and display the percent-encoded result in the right-hand output box.
- Copy the result: Click the Copy Output button to copy the encoded string to your clipboard. You can then paste it directly into your code, API client, or browser.
- Clear and repeat: Use the Clear button to reset both text areas and start fresh with new input.
This tool works entirely server-side using PHP, so it supports all Unicode characters, including Arabic, Chinese, Japanese, Cyrillic, and emoji — all of which will be correctly percent-encoded to their UTF-8 byte sequences.
Why is URL Encoding Important?
URL encoding is a fundamental requirement of web development. Here's why it matters in real-world applications:
- Query String Parameters: When building URLs with parameters (e.g.,
?search=hello world&lang=en), special characters must be encoded to avoid breaking the URL structure. An unencoded space would cause the URL to be malformed and the server would likely return an error. - API Requests: RESTful APIs and GraphQL endpoints often receive data via URL parameters. Any user-supplied input — such as search queries, usernames, or filter values — must be encoded to prevent injection attacks and parsing errors.
- Form Submissions: HTML forms with
method="GET"encode field values automatically, but when constructing URLs manually in JavaScript or PHP, you must encode values yourself usingencodeURIComponent()orurlencode(). - Internationalization (i18n): URLs containing non-ASCII characters (e.g., Spanish, Arabic, Chinese) must be percent-encoded to ensure they are correctly transmitted and understood by all HTTP implementations worldwide.
- Security: Proper URL encoding helps prevent certain classes of injection attacks, where a malicious user might attempt to embed control characters or special sequences into a URL to manipulate server-side logic.
URL Encoding Examples
Here are some common before-and-after examples to illustrate how percent-encoding transforms different types of characters:
hello world https://example.com/search?q=cats & dogs [email protected] price=£49.99 naïve résumé
hello+world https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dcats+%26+dogs user%40email.com price%3D%C2%A349.99 na%C3%AFve+r%C3%A9sum%C3%A9
Notice how the space becomes +, the colon and slashes are encoded, and the non-ASCII characters (£, ï, é) are converted to their multi-byte UTF-8 percent-encoded representations. This is the format expected by web servers and HTTP clients when processing URL query strings.
If you need to decode an encoded URL back to its original readable form, use our companion URL Decoder tool.