URL Encode/Decode

Encode special characters for URLs or decode percent-encoded URL strings. Essential for web development and API work.

How to Use

  1. Enter or paste your text or URL in the input area
  2. Click Encode to percent-encode special characters, or Decode to convert back
  3. Copy the result to use in your application

Frequently Asked Questions

  • What is URL encoding?

    URL encoding (also called percent-encoding) replaces special characters with a percent sign followed by their hexadecimal value. For example, a space becomes %20.

  • When should I URL encode?

    URL encode when including special characters in URL parameters, query strings, or form data that will be sent via HTTP.

  • What is the difference between encodeURI and encodeURIComponent?

    encodeURI encodes a full URI, preserving characters like :, /, and ?. encodeURIComponent encodes everything except letters, digits, and a few special characters, making it suitable for encoding individual parameter values.

  • Does this handle Unicode characters?

    Yes, Unicode characters are first encoded to UTF-8 bytes, then each byte is percent-encoded.

What Is URL Encoding?

URL encoding — formally called percent-encoding — is the process of replacing unsafe characters in a URL with a % sign followed by their two-digit hexadecimal representation. For example, a space becomes %20, an ampersand becomes %26, and a hash becomes %23.

URLs can only be transmitted over the internet using a limited subset of ASCII characters. Characters outside this safe set — including spaces, Unicode letters, punctuation, and control characters — must be encoded before being included in a URL.

When Do You Need URL Encoding?

Query string parameters: Any time you pass user input as a URL parameter, you must encode it. A search query like hello world & more must become hello%20world%20%26%20more to avoid being misinterpreted by the server.

API requests: REST APIs often require encoded parameters in the request URL, especially when passing strings that may contain special characters like +, =, or /.

Form submissions: HTML forms with method="GET" automatically encode form values before appending them to the URL. Understanding this encoding helps when debugging form submissions.

Redirect URLs: When passing a URL as a parameter to another URL (common in OAuth flows and redirects), the inner URL must be fully encoded.

encodeURI vs encodeURIComponent

JavaScript provides two built-in encoding functions, and the distinction matters:

  • encodeURI encodes a full URL. It leaves characters that are valid URL structure characters untouched: :, /, ?, #, [, ], @, !, $, &, ', (, ), *, +, ,, ;, =.
  • encodeURIComponent encodes everything except letters, digits, -, _, ., and ~. Use this when encoding a value that will be part of a query string.

Rule of thumb: use encodeURIComponent for individual parameter values; use encodeURI only if you need to encode an entire URL at once.

Unicode and UTF-8

Modern URLs support Unicode characters through a two-step process: the character is first encoded as UTF-8 bytes, then each byte is percent-encoded. For example, the Chinese character is encoded as %E4%B8%AD because its UTF-8 representation is the bytes E4 B8 AD. This tool handles this conversion automatically.