Skip to main content
CheckTown
Converters

URL Encoding & Decoding: Make URLs Web-Safe Instantly

Published 5 min read
In this article

What Is URL Encoding?

URL encoding (also called percent-encoding) converts characters that are unsafe or reserved in URLs into a safe format. Each unsafe character is replaced by a % sign followed by its two-digit hexadecimal ASCII code. For example, a space becomes %20 and an ampersand becomes %26.

URLs can only contain a limited set of ASCII characters. Characters outside this set — including spaces, non-ASCII letters, and special symbols — must be percent-encoded to be safely transmitted in a URL.

How URL Encoding Works

The encoder identifies characters that are not safe in URLs and replaces them with their percent-encoded equivalents.

  • Safe character detection — letters, digits, and - _ . ~ are left unchanged
  • Reserved character handling — ! * ' ( ) ; : @ & = + $ , / ? # [ ] are encoded in most contexts
  • Unicode support — non-ASCII characters are first UTF-8 encoded, then each byte is percent-encoded

Try it free — no signup required

Encode or Decode a URL →

When To Use URL Encoding

URL encoding is required whenever special characters appear in URL components.

  • Query parameters — encode values passed as query string parameters, especially user-supplied search terms
  • API requests — encode path segments and parameters when constructing API URLs programmatically
  • Form data — encode form data before appending to URLs in GET requests

Frequently Asked Questions

What is the difference between encodeURI and encodeURIComponent in JavaScript?

encodeURI encodes a complete URL and leaves characters like /, :, # intact because they have structural meaning in URLs. encodeURIComponent encodes a single URL component (like a query parameter value) and percent-encodes those structural characters too. For encoding individual parameter values, always use encodeURIComponent.

Why does a space sometimes show as + instead of %20?

The application/x-www-form-urlencoded format (used in HTML form submissions) encodes spaces as + rather than %20. This is a legacy convention from early web standards. In query strings from HTML forms, + means space; in other URL contexts, %20 is used. Both are valid, but the context determines which to use.

Do I need to encode the entire URL or just parts of it?

Only encode individual components (path segments, query parameter values). Encoding the entire URL would also encode the :, /, and ? characters that define the URL structure, breaking it. The rule: encode values, not the structural characters that form the URL.

Related Tools