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+bOutputa=hello+world&b=a%2BbSpace 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
URL Encoding
URL encoding (percent-encoding) converts characters not allowed in URLs into %HH form, so arbitrary data can appear safely in URL components. GLOSSARY
Percent-Encoding
Percent-encoding is the mechanism that converts unsafe characters in URLs into %HH form, defined by RFC 3986. GLOSSARY
URL
A URL (Uniform Resource Locator) is a string identifying the location of an Internet resource, comprising scheme, host, port, path, query, and fragment. GLOSSARY