URL Encode and Decode: Understanding Percent-Encoding for the Web

Learn what URL encoding (percent-encoding) is, why URLs need it, and how to encode and decode URLs. Essential for query parameters, APIs, and form data.

February 1, 2026

What Is URL Encoding?

URL encoding, also known as percent-encoding, is a mechanism for representing characters in a URL that are not allowed or have special meaning. It replaces unsafe characters with a percent sign (%) followed by two hexadecimal digits representing the character's ASCII code. For example, a space becomes %20, and an ampersand becomes %26. Our URL Encode and Decode tool makes these conversions instant and error-free.

Why Do URLs Need Encoding?

URLs (Uniform Resource Locators) have a strict syntax defined by RFC 3986. Only a limited set of characters is allowed in a URL without encoding:

  • Unreserved characters: A-Z, a-z, 0-9, hyphen (-), underscore (_), period (.), tilde (~)
  • Reserved characters: : / ? # [ ] @ ! $ & ' ( ) * + , ; = (these have special meaning in URL structure)

Any character outside this set must be percent-encoded. Additionally, reserved characters must be encoded when they appear in contexts where they are not serving their reserved purpose. For instance, if a query parameter value contains an ampersand, it must be encoded as %26 to prevent it from being interpreted as a parameter separator.

How Percent-Encoding Works

The encoding process converts each character to its UTF-8 byte representation, then represents each byte as a percent sign followed by two uppercase hexadecimal digits. For ASCII characters, this is straightforward: the space character (ASCII 32) becomes %20 because 32 in hexadecimal is 20. For non-ASCII characters like accented letters or emoji, the UTF-8 encoding produces multiple bytes, each prefixed with %.

For example, the German umlaut u (with two dots) encodes to %C3%BC in UTF-8, because it requires two bytes: C3 and BC. The Japanese character for mountain encodes to three bytes. This multi-byte encoding ensures that any Unicode character can be safely represented in a URL.

Common Characters That Need Encoding

Here are the most frequently encoded characters and their percent-encoded forms:

  • Space: %20 (or + in form data)
  • & (ampersand): %26
  • = (equals): %3D
  • ? (question mark): %3F
  • # (hash): %23
  • / (forward slash): %2F
  • + (plus): %2B
  • @ (at sign): %40
  • : (colon): %3A

Use Cases for URL Encoding

Query Parameters

When passing data through URL query strings, values must be properly encoded. A search query like cats & dogs in the URL becomes ?q=cats%20%26%20dogs. Without encoding, the ampersand would be misinterpreted as a parameter separator.

API Calls

RESTful APIs frequently require URL-encoded parameters in both GET and POST requests. Proper encoding ensures that special characters in search terms, filters, or identifiers do not break the request structure.

Form Data

HTML forms with application/x-www-form-urlencoded content type encode all form values using a variant of percent-encoding where spaces are represented as + instead of %20. This encoding is automatically applied by browsers when forms are submitted.

Redirect URLs

When a URL is passed as a parameter to a redirect endpoint, it must be fully encoded. The inner URL's special characters like ://, ?, and & need encoding to prevent them from interfering with the outer URL's structure.

Internationalized URLs

URLs containing non-Latin characters, such as Chinese, Arabic, or Cyrillic text, require percent-encoding. While modern browsers display decoded URLs in the address bar for readability, the actual HTTP request uses the encoded form.

Encoding vs. Decoding

Encoding converts readable text into its percent-encoded form for safe URL transport. Decoding reverses the process, converting percent-encoded strings back to their original characters. Both operations are essential when working with web applications, debugging API issues, or constructing dynamic URLs.

How to Use the URL Encode/Decode Tool

Enter any text to encode it for URL use, or paste an encoded URL string to decode it back to readable text. The tool handles all Unicode characters, multi-byte sequences, and edge cases correctly. It runs entirely in your browser with no data sent to any external server.

Best Practices

Always encode user-supplied input before inserting it into URLs. Use your programming language's built-in encoding functions like encodeURIComponent() in JavaScript or urllib.parse.quote() in Python. Never manually construct URLs with unencoded special characters, as this leads to broken links, security vulnerabilities, and data corruption.