About the URL Encoder / Decoder

URLs can only contain a limited set of ASCII characters. Spaces, accented letters, and symbols like &, =, #, and ? must be percent-encoded before use in a URL. Percent-encoding replaces each unsafe character with a % followed by its two-digit hexadecimal ASCII value: a space becomes %20, an ampersand becomes %26, and a hash becomes %23.

When do you need URL encoding?

encodeURI vs encodeURIComponent

In JavaScript, encodeURI encodes a full URL and leaves structural characters (/, ?, &, =) untouched. encodeURIComponent encodes everything including those characters, making it correct for encoding individual parameter values. Use encodeURIComponent for query string values.

URL encoding edge cases

Most URL encoding issues in practice come from edge cases: encoding the full URL when you should only encode parameter values (which breaks the URL structure), double-encoding (encoding an already-encoded string, turning %20 into %2520), and not encoding when submitting forms via JavaScript fetch where URLSearchParams handles encoding automatically.

Frequently Asked Questions

What does URL encoding do?
It converts special characters into a percent-sign followed by a two-digit hex code so they can be safely used in a URL. For example, a space becomes %20, a hash becomes %23, and a slash becomes %2F. This ensures the URL structure is not broken by characters that have special meaning.
Why does a space sometimes appear as + and sometimes as %20?
Both represent a space but in different contexts. %20 is standard RFC 3986 percent-encoding used in path segments. The + notation is application/x-www-form-urlencoded format used in HTML form submissions. Most web frameworks decode both correctly.
Do I need to encode every character in a URL?
No. Letters A-Z, digits 0-9, and the characters - _ . ~ are always safe and never need encoding. Characters like / : @ are valid in specific URL positions. Only characters that would be ambiguous in your specific context need encoding.
What is the difference between URL encoding and Base64?
URL encoding makes data safe for use inside URLs. Base64 encodes binary data as printable ASCII for embedding in text formats like HTML or email. They serve different purposes and should not be interchanged.
How do I URL encode a string in code?
JavaScript: encodeURIComponent("your text"). Python: from urllib.parse import quote; quote("your text"). PHP: urlencode("your text"). The encoded result replaces each special character with its %XX hex equivalent.
Related tools
Ad