encodeURIComponent vs encodeURI Playground

Glue a villager’s text into a URL, send it to the gudang, and see what becomes of the &, # and / inside it, and of a mismatched decode. An interactive…

Why it matters

A classic bug: & or = in user input leaks into a fake parameter, # cuts the URL, / shifts the path. Remember one rule: for one value (a query value, a path segment), encodeURIComponent, or let URLSearchParams encode it.

The key idea

encodeURIComponent for a value, encodeURI for a whole URL

Common mistakes

Try it in this playground