workspacereference / tools / guidesPUBLIC TOOLS
Forgegrid Tools
Browse ▾
LOCAL TOOL / URL

Encode a component, decode a string.

Handle URL query values and path segments safely using standard percent encoding.

02 / URL

Component encoding

Executed in this browser

Why component matters

The encoder uses encodeURIComponent, which is suitable for the value of a URL component rather than an entire URL. It also percent-encodes spaces, so a space becomes %20.

The decoder uses decodeURIComponent. A malformed percent sequence or invalid UTF-8 is reported as an error. The tool does not silently treat + as a space; HTML form encoding follows a different convention.

A URL component is one piece of a larger address, such as a query parameter value. Encoding a complete URL as though it were one component will also escape its separators and may change what a server receives. Decoding arbitrary percent sequences can fail when the input is malformed. Try a short sample with a space, an ampersand and a non-English character, then compare the result with the exact receiving context.

A practical way to use this page is to write down the behaviour described by “tools url”, then compare it with one observable example. Keep the actual result distinct from the assumption that motivated the test. When something differs, inspect the smallest relevant part before changing other settings.