Skip to content
Everyday Utilities Free • No signup • Instant results

URL Encode & Decode

Percent-encode or decode URLs and query parameters.

About the URL Encode & Decode

The URL Encode & Decode tool converts between plain text and percent-encoded URLs. URLs can only contain a limited set of ASCII characters (letters, digits, and a few symbols like - . _ ~); everything else — spaces, non-ASCII letters, emoji, query parameter values — must be percent-encoded as %XX sequences where XX is the hex value of the byte.

Two encoding modes are provided. encodeURI encodes a full URL but preserves the structural characters that give a URL its meaning (slashes, colons, question marks, ampersands, equals signs). encodeURIComponent encodes everything, including those structural characters — this is what you use when encoding a single query parameter value that may itself contain special characters.

The distinction matters in practice. If you encodeURIComponent a full URL, the slashes become %2F and the colons become %3A, which breaks the URL structure. If you encodeURI a single parameter value that contains an ampersand, the ampersand is preserved and the receiving server interprets it as a parameter separator — breaking your data. Using the right mode prevents both bugs.

How It Works

The tool uses JavaScript's native encodeURI, encodeURIComponent, decodeURI, and decodeURIComponent functions. These are defined in ECMAScript and behave identically across browsers.

encodeURI encodes everything except: A-Z a-z 0-9 ; , / ? : @ & = + $ - _ . ! ~ * ' ( ) #. These are the characters that have structural meaning in a URL (per RFC 3986). Use this when you have a complete URL and want to escape only the unsafe characters within it.

encodeURIComponent encodes everything except: A-Z a-z 0-9 - _ . ! ~ * ' ( ). Note that it encodes the structural characters (; , / ? : @ & = + $ #) because it assumes the input is a single component, not a full URL. Use this when encoding a query parameter value, a path segment, or any fragment that should not contain URL structural characters.

Decoding reverses the process: %20 becomes a space, %2F becomes a slash, %E2%82%AC becomes the euro sign (UTF-8 encoded as 3 bytes). Invalid percent sequences (like a lone % or %GG) will throw a URIError which the tool catches and reports.

Worked Examples

Encode the default URL “https://example.com/search?q=hello world&lang=en&page=2” without component mode (encodeURI). The space becomes %20 but the slashes, colons, ampersands, equals signs, and dots are preserved. The output is still a valid URL: https://example.com/search?q=hello%20world&lang=en&page=2. This is what you want when cleaning up a malformed URL.

Encode the same URL with component mode (encodeURIComponent). Now the colons become %3A, the slashes become %2F, and the ampersands become %26. The output looks like https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dhello%20world%26lang%3Den%26page%3D2 — this is no longer a usable URL but is safe to embed inside another URL as a parameter value (like ?redirect=https%3A%2F%2F...).

For decoding, paste an encoded URL and click Decode. If the input contains a malformed percent sequence (like %GG), the tool reports an error. Most real-world encoded URLs decode cleanly, but copy-pasted URLs that have been partially decoded by some other tool may have stray percent signs that need fixing.

When to Use This Tool

  • Encoding query parameter values that contain spaces, special characters, or non-ASCII text.
  • Cleaning up URLs that were typed or pasted with literal spaces.
  • Building redirect URLs where one URL is passed as a parameter inside another.
  • Decoding URLs that appear in analytics or log files to see the original text.
  • Debugging OAuth callback URLs that fail because of unencoded characters.
  • Encoding path segments that contain special characters (like file or product names).
  • Inspecting the encoding of cookies, headers, or other URL-embedded values.

Limitations & Disclaimer

This tool uses JavaScript's encodeURI/encodeURIComponent family, which follow RFC 2396 (an older standard) rather than the current RFC 3986. The differences are subtle (mostly around how ! and ' are handled) but can cause compatibility issues with strict parsers. The tool does not validate URL structure — it does not check that the input is a well-formed URL. Decoding may fail on inputs with malformed percent sequences. The tool does not handle the application/x-www-form-urlencoded format (which uses + for spaces) — replace + with %20 before decoding. See our disclaimer for full terms.

Frequently Asked Questions

When should I use encodeURI vs encodeURIComponent?

Use <code>encodeURI</code> when you have a complete URL and want to escape only the unsafe characters (spaces, non-ASCII) while preserving the structural characters (slashes, colons, ampersands). Use <code>encodeURIComponent</code> when encoding a single query parameter value or path segment that should not contain URL structural characters.

Why do spaces become %20 instead of +?

Both are valid encodings for a space. <code>%20</code> is the standard percent-encoding (RFC 3986). <code>+</code> is a legacy encoding from the <code>application/x-www-form-urlencoded</code> MIME type used in HTML form submissions. JavaScript's <code>encodeURIComponent</code> uses <code>%20</code>. To convert to <code>+</code> form, replace <code>%20</code> with <code>+</code> after encoding.

What characters do not need encoding?

Per RFC 3986, the unreserved characters <code>A-Z a-z 0-9 - _ . ~</code> never need encoding. All other characters either have structural meaning (and are preserved by encodeURI) or must be percent-encoded. The exact set depends on which part of the URL the character is in.

How are non-ASCII characters like emoji encoded?

Non-ASCII characters are UTF-8 encoded into bytes, then each byte is percent-encoded. An emoji like 😀 (U+1F600) becomes 4 UTF-8 bytes, which encode as <code>%F0%9F%98%80</code>. An accented letter like &eacute; (U+00E9) becomes 2 UTF-8 bytes, encoding as <code>%C3%A9</code>.

Why does decoding fail with 'URI malformed'?

The input contains an invalid percent sequence. Common causes: a lone <code>%</code> not followed by two hex digits, <code>%GG</code> (G is not a hex digit), or a partially-decoded URL where some percent sequences were already decoded. Fix the input by escaping stray percent signs as <code>%25</code> (the encoding for % itself).

Is my URL uploaded anywhere?

No. Encoding and decoding happen entirely in your browser using JavaScript's native URL functions. Your URLs &mdash; including any sensitive parameters like tokens or session IDs &mdash; never leave your device.

Last updated: July 21, 2026  ·  Author: HT99 Tools Editorial Team  ·  Reviewed by: HT99 Tools Editorial Team