toolfree

URL encoder

Percent-encode text for a URL in your browser, showing encodeURIComponent and encodeURI side by side so you can pick the right one.

Runs in your browser

Nothing to encode yet.

There are two answers, and the page shows both

This is the mistake worth avoiding, and it is why nothing here makes the choice for you.

encodeURIComponent escapes the delimiters — : / ? & = # — because it assumes the text is going inside a URL, as a query parameter or a path segment. If those characters survived, they would restructure the URL around them.

encodeURI leaves those alone, because it assumes you handed it a whole URL that just needs tidying — a space in it, or a Chinese character.

Getting it backwards is the classic bug. Put a URL into a query parameter with encodeURI and its ? and & merge into the outer URL, so ?next=https://x.com/a?b=1 silently becomes two parameters instead of one.

The status line tells you when the two differ, which is exactly when the choice matters.

Form encoding is a third thing

An HTML form does not send %20 for a space. It sends +, and it always has — application/x-www-form-urlencoded predates the modern URL rules and never caught up.

That is why decoding has a treat + as a space option. Percent-decoding a form value without it leaves literal plus signs in your text, and applying it to a normal URL turns a legitimate + into a space. There is no way to tell from the string alone, which is why it is a switch and not a guess.

Encoding something already encoded

%20 becomes %2520, and that is correct rather than a bug: % is itself a reserved character, so encoding it is the only way to represent a literal percent sign. A tool that quietly skipped already-encoded sequences could not encode 100% at all.

If you see %2520 in a URL, something has been encoded twice. Decode it twice.

Emoji and Chinese

Both encode as UTF-8 bytes, so one Chinese character becomes three percent escapes and most emoji become four. That is normal.

What is not normal, and what some tools get wrong, is splitting a character in half. Anything above U+FFFF — most emoji, and characters like 𝕏 — is stored as a surrogate pair, and encoding by index rather than by character produces two broken halves that decode to nothing. This encodes by character.

Nothing is uploaded

The text is encoded in this page. That matters here more than it might seem: URLs being debugged often carry tokens, session identifiers and API keys.