Utility

URL Encoder / Decoder

Encode or decode URL components and query strings instantly

Encoded result
Hello%20World!%20price%3D10%26currency%3D%E2%82%AC

50 characters

What Is URL Encoding (Percent-Encoding)?

URLs can only contain a limited set of ASCII characters. Any character outside that set β€” spaces, accented letters, symbols like &, =, #, and non-ASCII Unicode β€” must be percent-encoded before it can appear in a URL. Each such character is replaced by a % sign followed by two hexadecimal digits: space β†’ %20, € β†’ %E2%82%AC, δΈ­ β†’ %E4%B8%AD.

encodeURIComponent vs. encodeURI

JavaScript (and this tool) exposes two encoding functions:

  • encodeURIComponent β€” the safe default. Encodes everything except A–Z a–z 0–9 - _ . ! ~ * ' ( ). Use this for individual query parameter names and values, path segments, and any user-provided data that becomes part of a URL.
  • encodeURI (full URL mode) β€” encodes fewer characters. It leaves structural URL characters intact: : / ? # @ ! $ & ' ( ) * + , ; =. Use this only when encoding an already-assembled full URL that has valid structure but may contain spaces or non-ASCII characters.

Rule of thumb: when inserting a variable into a URL, always use component encoding. When you have a complete URL that just needs unsafe characters cleaned up, use full URL encoding.

Common Characters and Their Encodings

  • Space β†’ %20 (or + in query strings)
  • & β†’ %26
  • = β†’ %3D
  • + β†’ %2B
  • # β†’ %23
  • / β†’ %2F
  • ? β†’ %3F
  • @ β†’ %40
  • % β†’ %25

Security: Always Encode User Input in URLs

Failing to URL-encode user-provided data before inserting it into a URL is a common source of security vulnerabilities. An unencoded & in a redirect parameter can hijack the request to a different endpoint. An unencoded # truncates the URL at the fragment separator. Use this tool to verify your application is encoding correctly, and always encode on the server side as well when constructing URLs from user input.

Frequently Asked Questions

What is URL encoding?
URL encoding (also called percent-encoding) converts characters that are not allowed or have special meaning in URLs into a safe representation. Each unsafe character is replaced by a percent sign (%) followed by two hexadecimal digits representing the character's byte value. For example, a space becomes %20, & becomes %26, and = becomes %3D.
When do I need to URL encode?
You need URL encoding any time you include user-supplied data in a URL β€” search query parameters, form submissions, API calls, redirect URLs, OAuth tokens, and filenames in paths. Without encoding, characters like &, =, ?, #, and spaces break the URL structure. For example, the query "how to bake & decorate cakes" must be encoded as "how%20to%20bake%20%26%20decorate%20cakes" in a URL.
What is the difference between encodeURIComponent and encodeURI?
encodeURIComponent encodes everything except letters, digits, and - _ . ! ~ * ' ( ). Use it for individual query parameter values and path segments. encodeURI encodes fewer characters β€” it leaves structural URL characters intact (: / ? # @ ! $ & ' ( ) * + , ; =), so it is suitable for encoding a complete URL while preserving its structure. When in doubt, use encodeURIComponent for parts, encodeURI for full URLs.
Is URL encoding the same as Base64 encoding?
No. URL encoding replaces unsafe characters with %XX percent sequences while keeping the text mostly readable. Base64 encoding converts binary data (or any text) into a compact alphabet of 64 characters and looks nothing like the original. Base64 makes data larger by ~33% and is suited for embedding binary data in text contexts, while URL encoding is strictly for making arbitrary text safe to include in a URL.
Should I encode entire URLs or just query parameters?
Encode components, not the entire URL. Use encodeURIComponent on each query parameter name and value before assembling the full URL. Encoding the entire URL with encodeURIComponent would also encode the slashes, colons, and question marks that give a URL its structure, breaking it. The correct approach: build the base URL normally, then percent-encode each variable part.