URL Encoder
Percent-encode any text for safe use in URLs. Converts special characters to %XX format. Runs entirely in your browser.
What is URL Encoding?
URL encoding — formally called percent-encoding and defined in RFC 3986 — is the process of replacing characters that are not permitted in a URL with a percent sign followed by two hexadecimal digits representing the character's UTF-8 byte value. A space becomes %20, a hash becomes %23, and an at-sign becomes %40. The name "percent-encoding" comes from this % prefix pattern.
Only a small set of characters are allowed in URLs without encoding: unreserved characters (A–Z, a–z, 0–9, hyphen, underscore, period, tilde) and reserved characters that serve a structural purpose (slash, question mark, hash, ampersand, equals sign, etc.). Everything else must be percent-encoded before being placed in a URL.
encodeURIComponent vs encodeURI
JavaScript provides two encoding functions with different scopes. encodeURIComponent encodes everything except unreserved characters — including structural characters like / ? & = # :. Use it for individual query parameter values. encodeURI leaves structural characters intact and only encodes characters that are completely illegal in a URL. Use it to encode a full URL that already has correct structure. This tool uses encodeURIComponent, which is the safer choice for encoding values that will be inserted into a URL.
Common encoded characters
| Character | Encoded | Why it needs encoding |
|---|---|---|
| %20 | Space is not allowed in URLs | |
| & | %26 | Delimiter between query parameters |
| = | %3D | Separates key from value in query strings |
| # | %23 | Fragment identifier — would truncate the URL |
| + | %2B | Interpreted as a space in form data |
| / | %2F | Path separator — needs encoding inside a value |
| ? | %3F | Query string start — needs encoding inside a value |
| @ | %40 | Used in authority section (user:pass@host) |
When to URL-encode
- Query string values — always encode parameter values before appending to a URL:
?q=hello+worldshould be?q=hello%20world(or use+for form encoding). - API requests — when constructing URLs in code, encode each value individually with
encodeURIComponentbefore concatenation. - Redirect URLs — a URL passed as a redirect parameter must be fully encoded so the receiving server can parse it as a single value.
- File names in paths — spaces and special characters in file names must be percent-encoded when used in a URL path segment.
Frequently asked questions
What is the difference between %20 and + for spaces?
%20 is the RFC 3986 percent-encoding of a space and works everywhere in a URL. The + sign represents a space only in the query string of application/x-www-form-urlencoded data (HTML forms). In a URL path, + is a literal plus sign. Prefer %20 to avoid ambiguity.
Can double encoding cause problems?
Yes. If you encode an already-encoded string, the % itself gets encoded as %25, producing %2520 instead of %20. Servers will decode it to %20 (literal percent-twenty), not a space. Always encode raw values, never pre-encoded ones.
If jsondecode.com saved you time, share it with your team
Free forever. No ads. No sign-up. Help other developers find it.