URL Encoder and Decoder

Percent-encoding in both directions, with the component and whole-URL rules kept apart.

A URL can only carry a restricted set of characters, and several of those characters mean something structural: a question mark opens the query string, an ampersand separates parameters, a hash starts the fragment. Anything else has to be percent-encoded. Which characters count as "anything else" depends on whether you are encoding one value or an entire address — a distinction this tool makes explicit rather than guessing.

How it works

1

Choose encode or decode

The same rules apply in reverse when decoding.

2

Pick the scope

A single component encodes the structural characters too; a whole URL leaves them working.

3

Copy, or swap the result back in

Chaining a decode after an encode is a quick way to check a round trip.

Component or whole URL — the mistake behind most broken links

JavaScript offers two functions and the difference matters. encodeURIComponent escapes everything that is not unreserved, including & ? = / # +, and is correct for a single value being dropped into a query string. encodeURI leaves those characters alone because it assumes you are handing it a complete, already-structured address that must keep working.

Using the wrong one fails in opposite directions. Encode a whole URL with the component function and https://example.com/ becomes https%3A%2F%2Fexample.com%2F — a valid string that is no longer a link. Encode a single value with the URL function and a search term containing an ampersand splits into two parameters, silently truncating the search.

The rule that avoids both: encode values, not addresses. Build the URL from its parts, run each value through component encoding as you insert it, and never encode the assembled result a second time. Double-encoding turns %20 into %2520, which is one of the harder bugs to spot because it looks almost right.

Why a space is sometimes %20 and sometimes +

Both are correct, in different places. The percent-encoding standard defines a space as %20 and that form is valid anywhere in a URL. The plus sign comes from HTML form submission, where the application/x-www-form-urlencoded content type has encoded spaces as + since the earliest browsers and continues to for compatibility.

The consequence is a genuine ambiguity in query strings. A server parsing form-encoded data reads + as a space, so a literal plus sign in a value — a phone number such as +41 44 123, or a search for C++ — must itself be encoded as %2B or it disappears. Inside a URL path, by contrast, a plus is just a plus and no decoder converts it.

The safe default is %20, which every parser reads as a space in every position. Turn on the form-encoding option only when you are reproducing what a browser sends from an HTML form, or matching an existing API that expects that style.

Frequently Asked Questions

Component encoding escapes the structural characters & ? = / # as well, which is what a single query value needs. Whole-URL encoding leaves them intact so the address keeps working.
Most likely the whole address was encoded as a component, turning the colon and slashes into %3A and %2F. Encode individual values as you assemble the URL, not the finished result.
%20 is valid everywhere and is the safe default. The plus sign comes from HTML form encoding and is only read as a space by parsers expecting that format.
Encoding an already-encoded string, which turns the % of %20 into %25 and produces %2520. The result decodes to %20 rather than a space, so the value arrives visibly wrong.
The unreserved set: A to Z, a to z, 0 to 9, and the four marks - _ . ~ . Everything else is either reserved for structure or must be percent-encoded.