← Web security

URL encoder / decoder

Three flavors covered: encodeURI, encodeURIComponent, and form-urlencoded (+ for space). Pick the right one before pasting it into a request.

Plain text

Mode:

Component encoder — percent-encodes everything except A-Z, a-z, 0-9, - _ . ! ~ * ' (). Use for query values, path segments.

Which mode? encodeURIComponent is right ~95% of the time — use it for query-string values, path segments, fragment text. Reach for encodeURI only when you have a whole URL and want to keep the structure intact. Use form mode when building application/x-www-form-urlencoded bodies — the server will turn + back into a space.