Skip to content
uencoder

URL Encoding

URL encoding (percent-encoding) converts characters not allowed in URLs into %HH form, so arbitrary data can appear safely in URL components.

Purpose

It keeps reserved characters (such as /, ?, #, =) and non-ASCII characters from breaking URL structure, while remaining reversibly round-trippable.

Mechanism

Unsafe characters are converted byte-by-byte into % followed by two uppercase hexadecimal digits. RFC 3986 defines the reserved character sets; the HTML5 application/x-www-form-urlencoded form additionally encodes a space as +. Modern browsers and the fetch API handle this automatically.

Use cases

  • Passing non-ASCII text and special characters in URL query parameters
  • RESTful API path parameter encoding
  • OAuth callback URL encoding
  • Subject and body in mailto links

Examples

  • Input
    a b&c
    Output
    a%20b%26c

    RFC 3986 form; the form-encoded variant is a+b%26c

Common errors

Encoding the entire URL instead of just the parameter values
Encode parameter values only and keep the /?=& delimiters

Related terms

Related tools

Related tutorials

References