Skip to content
uencoder

Form Encoding

Form encoding (application/x-www-form-urlencoded) is how HTML forms encode key-value pairs on submission, encoding spaces as + instead of %20.

Purpose

It provided a more lenient encoding than RFC 3986 for early web form submission, staying compatible with historical implementations.

Mechanism

Keys and values are each percent-encoded, but a space becomes + instead of %20; pairs are joined with = and separated by &. Non-ASCII characters are first converted to bytes in the page charset (usually UTF-8) and then percent-encoded.

Use cases

  • HTML form GET/POST submission
  • OAuth 1.0 signature parameter encoding
  • API application/x-www-form-urlencoded request bodies
  • fetch body with URLSearchParams

Examples

  • Input
    a=hello world&b=a+b
    Output
    a=hello+world&b=a%2Bb

    Space becomes +, and + becomes %2B

Common errors

Encoding a space as %20 instead of +, causing server-side parsing differences
Use URLSearchParams for form scenarios and encodeURIComponent for URL components

Related terms

Related tools

References