URL Encoder / Decoder

Encode special characters for safe use in URLs, or decode percent-encoded strings back to readable text.

How to Use the URL Encoder / Decoder

This tool helps developers safely encode text for use in URLs or decode percent-encoded URLs back to readable form. Whether you are building query strings, debugging API requests, or parsing incoming URLs, this utility handles it instantly in your browser with no server-side processing.

  1. Select a mode: Choose Encode to convert plain text to a URL-safe string, or Decode to convert a percent-encoded string to plain text.
  2. Choose the encoding function: encodeURIComponent (default) encodes everything for use in query parameter values. encodeURI preserves URL structural characters and is meant for encoding entire URLs.
  3. Enter your text: Paste or type the content you want to encode or decode into the input field.
  4. Click Convert: The encoded or decoded result appears in the output field, ready to copy.

URL Encoding Reference

Percent-encoding replaces unsafe characters with a % sign followed by the two-digit hexadecimal value of the character's byte. Here are common examples:

CharacterEncodedDescription
(space)%20Space character
&%26Ampersand — separates query parameters
=%3DEquals — separates key-value pairs
?%3FQuestion mark — starts query string
#%23Hash — fragment identifier
/%2FForward slash — path separator
+%2BPlus sign

When to Use Each Encoding Function

Choosing the correct encoding function prevents subtle bugs in URLs. Use encodeURIComponent when encoding individual query parameter values, form data, or any text fragment that will be embedded inside a URL. This function encodes characters like / ? # & = that would otherwise interfere with URL structure.

Use encodeURI when you have a complete URL that is already well-formed and you only need to encode characters that are not valid in URLs at all, such as spaces or non-ASCII characters. This function deliberately leaves structural characters untouched so the URL remains navigable.

Practical Examples

  • API query string: ?search=hello%20world&lang=en — the space in "hello world" must be encoded as %20.
  • Redirect URL parameter: ?redirect=https%3A%2F%2Fexample.com%2Fpage — the inner URL must be fully encoded when used as a parameter value.
  • Email mailto link: mailto:[email protected]?subject=Hello%20World — spaces in the subject line need encoding.

Frequently Asked Questions

What is the difference between encodeURI and encodeURIComponent?

encodeURI encodes a full URL but preserves characters that have special meaning in URLs such as colons, slashes, question marks, and hash symbols. encodeURIComponent encodes everything except letters, digits, and a few safe characters like hyphens and underscores. Use encodeURIComponent for query parameter values and encodeURI when encoding an entire URL that should remain navigable.

Why do I need to URL-encode special characters?

URLs can only contain a limited set of ASCII characters. Special characters like spaces, ampersands, equals signs, and non-ASCII characters must be percent-encoded (e.g. space becomes %20) so that servers and browsers interpret the URL correctly. Without encoding, these characters can break the URL structure or be misinterpreted.

Can I decode a full URL with query parameters?

Yes. Paste the entire percent-encoded URL into the input field, select Decode mode, and click Convert. The tool will replace all percent-encoded sequences (like %20, %3D, %26) with their original characters so you can read the URL in plain text.