URL Encode
Percent-encode URLs and query strings — convert special characters to %XX format for safe URL transmission.
What is URL Encoding?
URL encoding (also called percent-encoding) is a mechanism for encoding special characters in a URL by replacing them with a percent sign (%) followed by two hexadecimal digits representing the character's byte value. For example, a space becomes %20, # becomes %23, and & becomes %26.
URLs can only contain a limited set of safe characters defined by RFC 3986. Any character outside this set — including spaces, Unicode characters, most punctuation, and all non-ASCII characters — must be percent-encoded before being included in a URL. This ensures the URL is valid and can be correctly parsed by web browsers, servers, and HTTP clients.
There are three common encoding modes: encodeURIComponent encodes everything except A–Z, a–z, 0–9, -, _, ., !, ~, *, ', (, ) — ideal for encoding individual query parameter values. encodeURI preserves the URL structure characters (/, :, ?, #, &, =) and only encodes non-URL characters — used for encoding a complete URL. Form encoding (application/x-www-form-urlencoded) replaces spaces with + instead of %20 — used in HTML form submissions.
Common use cases include encoding search queries in URL parameters, encoding file paths for web APIs, building dynamic URLs in JavaScript, and preparing query strings for HTTP requests.