URL Encoder & Decoder

Encode and decode URLs instantly. Both encodeURIComponent and encodeURI modes.

Last updated: April 2026
Input
Output

What is URL Encoding?

URL encoding (percent encoding) replaces unsafe characters in URLs with a percent sign followed by their hex code. For example, a space becomes %20 and an ampersand becomes %26. This ensures URLs work correctly across all browsers and servers.

encodeURIComponent vs encodeURI

JavaScript provides two functions: encodeURIComponent encodes everything except letters, digits, and a few special characters — use this for query parameter values. encodeURI preserves the URL structure (://?#) and only encodes characters that are invalid in a complete URL — use this for encoding full URLs.

Common Use Cases

URL encoding is essential when building API query strings, passing user input in URLs, creating shareable links with special characters, and debugging encoded URLs received from third-party services.

Frequently Asked Questions

When should I use encodeURIComponent vs encodeURI?

Use encodeURIComponent for individual parameter values — it encodes everything except letters, digits, and - _ . ~ characters. Use encodeURI for complete URLs — it preserves the URL structure (://?#&=) and only encodes characters that are invalid in a full URL. Using the wrong function is a common source of broken API calls.

Why do I see %20 instead of spaces in URLs?

The %20 is the percent-encoded form of a space character. URL encoding replaces unsafe characters with a percent sign followed by their hexadecimal code. Spaces can also appear as + in query strings (application/x-www-form-urlencoded format). Both are valid but %20 is the standard for URIs.

Can URL encoding prevent security vulnerabilities?

Proper URL encoding is essential for preventing injection attacks. Without encoding, user input containing characters like &, =, ?, or # can break URL parsing or inject unwanted parameters. Always encode user-supplied values before inserting them into URLs, API endpoints, or redirect paths.

Is my data sent to a server when I encode URLs here?

No. This tool uses JavaScript built-in encodeURIComponent() and encodeURI() functions that run entirely in your browser. Your URLs and data never leave your device. This is particularly important when encoding URLs that contain API keys, tokens, or authentication parameters.