How to URL Encode & Decode Strings (Percent-Encoding Explained)

Published: 2026-02-12 | Read Time: 3 min read

Safely encode special characters (spaces, ampersands, slashes, non-ASCII characters) for HTTP GET query parameters and decode URL encoded strings.

Frequently Asked Questions

What is the difference between encodeURI and encodeURIComponent?
`encodeURI` preserves protocol and path separators (`://`, `/`, `?`), while `encodeURIComponent` encodes all characters including slashes and question marks for safe parameter values.