Toolbit

URL Encoder & Decoder

Percent-encode and decode text for URLs, query parameters, and forms, and break a URL down into its parts and parameters.

What URL encoding is

A URL can only contain a small set of ASCII characters: unaccented letters, digits, and a handful of symbols. On top of that, some of those symbols carry meaning: / separates path segments, ? starts the query string, & separates parameters, = joins a name to its value, and # introduces the fragment. To include any other character — or to use one of those symbols as data rather than as a delimiter — you use percent-encoding, defined in RFC 3986.

The rule is simple: the character is converted to bytes using UTF-8, and each byte is written as % followed by its two-digit hexadecimal value. A space is byte 0x20, so it becomes %20; ñ takes two bytes in UTF-8 (0xC3 0xB1) and becomes %C3%B1; the € sign takes three and ends up as %E2%82%AC.

The three modes and when to use each

The key question before encoding is which part of the URL you're building, because that determines which characters need protecting:

  • Component (encodeURIComponent): for a single value that will go inside a URL, such as a parameter value (?q=…) or one path segment. It also encodes / ? & = #, because inside a value those characters are data and must not be mistaken for delimiters. This is the right mode in the vast majority of cases.
  • Full URL (encodeURI): for an entire URL whose structure is already in place and that just contains a stray space or accented letter. It leaves every delimiter alone, so it should never be used on a value: if the value contains &, the result splits the parameter in two.
  • Form (application/x-www-form-urlencoded): the format browsers use to submit HTML forms, and what URLSearchParams produces. It's nearly identical to component mode, but turns spaces into + and also encodes ! ' ( ) ~.

Reference table

How each common character comes out in each mode:

CharacterComponentFull URLForm
space%20%20+
&%26&%26
/%2F/%2F
?%3F?%3F
=%3D=%3D
#%23#%23
+%2B+%2B
:%3A:%3A
@%40@%40
%%25%25%25
~~~%7E
ñ%C3%B1%C3%B1%C3%B1
€%E2%82%AC%E2%82%AC%E2%82%AC

Two rows deserve a closer look. A literal + inside a value must always be encoded as %2B, because on the server side many libraries read + in a query string as a space. And % itself encodes to %25 — the telltale sign of double encoding, where an already-encoded value gets encoded again and %20 turns into %2520.

Decoding and catching errors

When decoding, the tool turns each %XX sequence back into its byte and reassembles the UTF-8 characters. In form mode it also reads + as a space. If it finds a % not followed by two hex digits (an unencoded 100%, say), or a run of bytes that doesn't form a valid UTF-8 character (an ñ missing its second byte), it reports the exact sequence and its position — instead of JavaScript's generic URIError: URI malformed.

Parsing a URL

The second part of the tool breaks an absolute URL into its components (protocol, username, host, port, path, and fragment) and lists the query string parameters already decoded, in their original order and keeping duplicates. It uses the same URL API browsers do, so the result is exactly what a web application would see. It's handy for inspecting long links stuffed with tracking parameters, debugging login redirects, or figuring out what a server actually receives.

Common mistakes

  • Building URLs by string concatenation. "https://api.example.com/search?q=" + "salt & pepper" produces a URL where the server receives q=salt plus an empty parameter named pepper. Encode the value in component mode — or better, build the URL with URL and URLSearchParams.
  • Using encodeURI on a parameter. It doesn't encode & or =, so it has the same problem as concatenation.
  • Encoding twice. If a value already went through an encoder, running it again turns every % into %25.
  • Mixing up + and %20. Both mean a space in a form-style query string, but in a URL's path, + is a literal plus sign.

Each case is covered in detail, with examples in several languages, in URL Encoding Explained: Percent-Encoding, %20, and +.

Privacy

Encoding, decoding, and URL parsing all happen in your browser. Nothing you type is sent to a server or saved in this page's URL.

Frequently asked questions

Why does a space sometimes show up as %20 and sometimes as +?

Because there are two formats. RFC 3986, which governs URLs in general, encodes a space as %20. The HTML form format (application/x-www-form-urlencoded), used by browsers when submitting forms and by URLSearchParams, encodes it as +. In a query string both are usually read as a space, but in a URL's path a + is a literal plus sign.

What's the difference between encodeURI and encodeURIComponent?

encodeURI is meant for a whole URL: it leaves delimiters like / ? & = # untouched so the structure stays intact. encodeURIComponent is meant for a value going inside a URL and encodes those delimiters too. For a parameter value, encodeURIComponent is always the right call; with encodeURI, an & inside the value would split the parameter in two.

Do accented letters and ñ need to be encoded in a URL?

Yes. RFC 3986 only allows ASCII, so in the path and query string characters like é or ñ travel UTF-8 encoded (%C3%A9, %C3%B1). Browsers display them decoded in the address bar for readability, but send them encoded. Domain names use a different mechanism, Punycode: münchen.de becomes xn--mnchen-3ya.de.