Developer

URL encode and decode

Encode uses encodeURIComponent, which is the right call for a query value. Decode reverses a percent-encoded string.

Encoding stays in this browser. Nothing is uploaded.

How it works

Encoding escapes every character that is not an unreserved URL character. A space becomes %20, a slash becomes %2F, and a question mark becomes %3F. That is what you want inside a query parameter. It is more aggressive than encodeURI, which would leave the slash alone.

Decoding turns %20 back into a space. A stray % that is not followed by two hex digits is an error, and the page says so instead of returning a broken string. Nothing is uploaded.

Formula

  • Space
    a b → a%20b
  • Slash
    a/c → a%2Fc

Worked examples

A query value

“a b/c?x=1” encodes to a%20b%2Fc%3Fx%3D1. Drop that into a single parameter without the parameter breaking on the slash or the question mark.

A bad percent

A lone % does not decode. The page reports that the encoding is not valid.

Characters people hit first
CharacterEncodedWhy
Space%20Otherwise it splits the query
/%2FOtherwise it looks like a path
?%3FOtherwise it starts a new query
=%3DOtherwise it looks like another parameter

Common questions

Is the text uploaded?

No. Encoding runs in your browser.

Why not encodeURI?

encodeURI is for a whole URL and leaves / ? & = alone. encodeURIComponent is for one value. This page uses the component form.

Does + mean a space?

Not here. A space encodes as %20. Some form bodies use +. This decoder does not treat + as a space.

What about Unicode?

Characters outside ASCII are UTF-8 percent-encoded, so é survives a round trip.