What is URL Encoding?

URL Encoding (Percent-Encoding) is a mechanism for encoding information in a Uniform Resource Identifier (URI) by replacing unsafe ASCII characters with a '%' followed by two hexadecimal digits representing the character's byte value.

Quick Facts

Full NamePercent-Encoding / URL Encoding
Created1994 (RFC 1738, updated in RFC 3986 in 2005)
SpecificationOfficial Specification

How URL Encoding Works

URL encoding ensures that URLs only contain valid ASCII characters. Characters that have special meaning in URLs (like &, =, ?, /) or are not allowed (like spaces, non-ASCII characters) must be encoded. For example, a space becomes %20, and an ampersand becomes %26. This encoding is essential for passing data in query strings, form submissions, and API requests. Modern web applications typically handle URL encoding automatically, but understanding it is crucial for debugging and API development.

Key Characteristics

  • Replaces unsafe characters with %XX hexadecimal format
  • Space can be encoded as %20 or + (in form data)
  • Preserves alphanumeric characters (A-Z, a-z, 0-9)
  • Safe characters include - _ . ~
  • UTF-8 characters are encoded as multiple %XX sequences
  • Case-insensitive for hex digits (%2f equals %2F)

Common Use Cases

  1. Query string parameters in URLs
  2. Form data submission (application/x-www-form-urlencoded)
  3. API request parameters
  4. Encoding special characters in file paths
  5. Creating safe URLs for sharing

Example

Original: Hello World!
Encoded:  Hello%20World%21

Original: name=John Doe&city=New York
Encoded:  name=John%20Doe&city=New%20York

Original: https://example.com/search?q=C++ programming
Encoded:  https://example.com/search?q=C%2B%2B%20programming

Related Tools on QubitTool

Related Concepts