Encode URL

Percent-encode a string for URLs - encodeURIComponent or encodeURI. Live preview, stats. Free, offline, client-side, instant, secure.

Percent-encode a string for URLs. Pick encodeURIComponent (for query-parameter values - encodes everything special) or encodeURI (for whole URLs - preserves / ? # : @ etc).

- paste text to begin

How to Use Encode URL

  1. Paste your text into the input box.
  2. Pick a mode. Keep "encode as URI component" on (default) for query-parameter values like ?q=… - that encodes everything special including &, =, /. Turn it off for whole URLs like https://x.com/a b - that preserves : / ? # & = @ etc.
  3. Read the stats line - input vs output length, the percentage size increase, and how many percent-escapes the output contains.
  4. Copy or download the encoded string. Ctrl/Cmd + Enter copies.

Frequently Asked Questions

What’s the difference between encodeURI and encodeURIComponent?

encodeURI assumes the input is a complete URL and preserves the characters that have syntactic meaning in URLs: ; , / ? : @ & = + $ # (plus the unreserved set). encodeURIComponent assumes the input is a single component of a URL (a parameter value, a path segment) and encodes all the reserved characters too. Rule of thumb: use encodeURIComponent for parameter values; use encodeURI only when the input is already a syntactically structured URL.

Why doesn’t this handle + for spaces?

Pure URL encoding (RFC 3986) uses %20 for space. The +-for-space convention only applies to the application/x-www-form-urlencoded form-submission format, which is technically different from URL encoding even though browsers often blur the line. If your target system expects + for spaces in query strings, you can post-process the output with .replace(/%20/g, '+'). The native browser encodeURIComponent always emits %20.

What does the percent-escape count mean?

It’s the number of %XX sequences in the output – one per byte that had to be escaped. A single emoji like 🎉 (U+1F389) becomes 4 bytes in UTF-8, so 4 percent-escapes (%F0%9F%8E%89). The character count goes up by 11 – useful for sanity-checking that you’re inside any URL length limit downstream services impose (often 2,000 or 8,000 bytes for the whole URL).

Are Unicode characters handled?

Yes. encodeURIComponent and encodeURI both convert non-ASCII characters to their UTF-8 byte representation and then percent-encode each byte. So "café" becomes "caf%C3%A9" and emoji like 🚀 becomes %F0%9F%9A%80. The only edge case is “lone surrogate” code points (an unpaired half of a surrogate pair) – those throw URIError; the tool catches the error and shows it in the stats line instead of crashing.

Do I need to encode the whole URL?

Usually not. The scheme (https://), host (example.com), and path separators (/) are part of the URL grammar and should not be percent-encoded. What you encode is the parts that contain arbitrary user input: query-parameter values, fragment identifiers, sometimes path segments containing non-ASCII. The two modes here help you pick the right scope.

Can I decode the output back?

Not in this tool – has a separate URL decoder for that. Or in any browser console: decodeURIComponent("%E2%9C%93") returns "✓".

Is anything sent to a server?

No. The page loads three static files (HTML, CSS, JS) and then runs entirely in your browser. You can disconnect from the internet after the page loads. No analytics, no tracking, no cookies.

Is this tool free?

Yes – free, unlimited, no signup, no watermark. Use the output in any context. Attribution to is appreciated but not required.