URL Encoder / Decoder

Percent-encode a value for a URL, or decode one, with the functions built into your browser.

What this encoder does

Type or paste text on the left and press Encode. Depending on the Mode switch, the page calls your browser's encodeURIComponent() (the default) or encodeURI() and shows the result on the right. Decode runs decodeURIComponent() or decodeURI() the other way. Everything happens in the page's JavaScript; the text is not sent to our server.

The two modes answer different questions. Given cats & dogs café/x?y=1#z, component mode produces cats%20%26%20dogs%20caf%C3%A9%2Fx%3Fy%3D1%23z: every character that could be mistaken for URL structure is encoded, which is what you want for a single value that will sit inside a query string. URI mode produces cats%20&%20dogs%20caf%C3%A9/x?y=1#z: the spaces and the accent are encoded but &, /, ?, = and # are kept, which is what you want when the text is a whole URL whose structure must survive.

How percent-encoding works

RFC 3986, the URI standard, allows only a small set of characters to appear literally. Anything else is written as a percent sign followed by two hexadecimal digits giving the byte value: a space becomes %20, & becomes %26, / becomes %2F and the percent sign itself becomes %25. Characters outside ASCII are first converted to UTF-8 and then each byte is encoded, so é becomes %C3%A9 and a single emoji becomes four %XX groups.

The standard splits characters into unreserved ones (A-Z a-z 0-9 - . _ ~), which never need encoding, and reserved ones (: / ? # [ ] @ ! $ & ' ( ) * + , ; =), which have a structural meaning and must be encoded whenever they appear as data rather than as a delimiter. An ampersand inside a search term is data; the ampersand between two parameters is a delimiter. Encoding is how a URL tells the two apart.

When you need it

  • Query values with special characters: a search for cats & dogs must travel as q=cats%20%26%20dogs, or the server sees a second parameter named dogs.
  • A URL inside a URL: redirect= and return_to= parameters carry a whole address, which must be encoded in component mode so that its own ? and & do not break the outer URL.
  • Paths with spaces or accents: a file called résumé 2026.pdf is requested as r%C3%A9sum%C3%A9%202026.pdf.
  • URLs built in code: any value you join into a URL by string concatenation should pass through encodeURIComponent() first. Forgetting it is a common cause of broken links and of injection bugs.
  • Reading a URL someone sent you: paste the encoded query string here and decode it to see the real values.

Reserved and unreserved characters

TypeCharacters
UnreservedA-Z a-z 0-9 - . _ ~
Reserved: / ? # [ ] @ ! $ & ' ( ) * + , ; =
Space%20 everywhere; + only in form-encoded query strings
Percent%25, so that a literal percent sign is not read as the start of an escape

encodeURIComponent vs encodeURI, and what decoding leaves alone

FunctionLeaves unencodedUse it for
encodeURIComponent()A-Z a-z 0-9 - _ . ! ~ * ' ( )One value: a query parameter, a path segment, a URL that is itself a parameter
encodeURI()The same set plus ; / ? : @ & = + $ , #A complete URL whose delimiters must keep their meaning

JavaScript leaves ! * ' ( ) unencoded although RFC 3986 reserves them. Most servers do not mind; a few APIs and the OAuth 1.0 signature rules want them encoded too, and MDN shows the extra replacement needed. Decoding has its own rules: decodeURI() deliberately leaves %2F, %3F, %23 and the other delimiter escapes as they are, because it assumes they were encoded on purpose, while decodeURIComponent() decodes everything. Neither function turns + into a space, and both stop with "URI malformed" when they meet an incomplete escape such as %E0%A4%A or bytes that are not valid UTF-8.

Frequently asked questions

Should a space be %20 or +?

Both are seen in the wild. %20 is the percent-encoding defined by RFC 3986 and works anywhere in a URL. + means a space only in the application/x-www-form-urlencoded format that HTML forms use for query strings, defined in the WHATWG URL Standard. This tool always produces %20 and, when decoding, leaves + as a plus sign; replace it with %20 first if your text came from a form submission.

Why does decoding fail with "URI malformed"?

The text contains a percent sign that does not start a valid escape: a lone %, a % followed by fewer than two hex digits, or a sequence such as %E9 that is a valid Latin-1 byte but not valid UTF-8. Find the stray percent sign and encode it as %25, or decode the text with the character set it was encoded in.

Can I encode a whole URL with encodeURIComponent?

Only when that URL is going to be a parameter value inside another URL. Component mode turns https://example.com/a?b=1 into https%3A%2F%2Fexample.com%2Fa%3Fb%3D1, a single opaque value. If you want the address itself to stay usable, choose URI mode, which encodes spaces and non-ASCII characters and keeps the structure.

Is my text sent to a server?

No. Encoding and decoding use the functions built into your browser, inside this page, and no request carries your text. Like every page on this site, it loads the Ahrefs Web Analytics script, which records the visit, not what you type.

Related tools: paste the finished address into the URL parser to see how a browser splits it and decodes each parameter, and into the URL status checker to confirm that the server answers it. Base64 output placed in a query string needs encoding here as well, because +, / and = are reserved; the Base64 converter explains the URL-safe variant.