URL encoder and decoder — encodeURIComponent or encodeURI, both ways

Percent-encode text for a URL, or decode it back, choosing component mode (encodeURIComponent, for a single query value or path segment) or full-URL mode (encodeURI, which keeps the URL's structure), with an option to write spaces as +.

Live demo · real result from this tool
Mode
Scope

Encoded

https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dcaf%C3%A9%20%26%20cr%C3%A8me%26page%3D2

Processed on your device — nothing is uploaded.

How to use the URL encoder and decoder

  1. Paste text into Text. The default is a sample search URL with accents and spaces.
  2. Choose Mode: Encode or Decode.
  3. Choose Scope: Component (encodeURIComponent) or Full URL (encodeURI).
  4. Tick Spaces as + (form encoding) if you need form-style spaces.
  5. Copy the Encoded or Decoded result.

What it does and when to use it

URLs may only contain a limited set of ASCII characters. Everything else, from spaces and & to é and emoji, must be written as % followed by hex bytes. Use this tool when you build a link by hand, debug a redirect that loses part of its query string, read an encoded value from a server log, or check what your code should produce.

To build a full query string from key–value pairs, use the query string builder, or turn a JSON object into one with JSON to query string. To split a URL into protocol, host, path and parameters, use the URL parser.

How it works

Text is converted to UTF-8 bytes, and each byte outside the allowed set is written as %XX, as described in RFC 3986. The tool calls JavaScript’s built-in functions in your browser:

  • Component uses encodeURIComponent and decodeURIComponent. Reserved characters such as / ? & = # are escaped too.
  • Full URL uses encodeURI and decodeURI. Reserved characters are kept, and when decoding, escapes such as %2F and %26 stay as they are.
  • Spaces as + swaps %20 for + after encoding, and swaps + for a space before decoding.

Worked examples

Component mode on a value with reserved characters, a b&c=d/é:

a%20b%26c%3Dd%2F%C3%A9

é becomes two bytes, %C3%A9, because UTF-8 uses two bytes for it.

Full URL mode on the default sample shows the classic trap:

Input:  https://example.com/search?q=café & crème&page=2
Output: https://example.com/search?q=caf%C3%A9%20&%20cr%C3%A8me&page=2

The & inside the search term is left as is, so a server reads q=café and a stray parameter crème. Encode the value café & crème in Component mode instead, which gives caf%C3%A9%20%26%20cr%C3%A8me.

Decoding form data with Spaces as + ticked, caf%C3%A9+au+lait gives café au lait.

Limits and tips

  • Encode once. Running encoded text through again turns %20 into %2520. If you see %25 in a URL, something encoded twice.
  • No validation. The tool does not check that a URL is well formed or that its host exists.
  • Decoding can change meaning. Decoding a whole URL in Component mode turns %26 into a real &, which splits the value.

Frequently asked questions

Which mode should I use?
Use Component for anything you insert into a URL, such as a search term, a redirect target or a path segment. Use Full URL only for a complete address that you trust is already split correctly and just needs spaces and non-ASCII characters escaped.
Why does Full URL mode leave & and = alone?
encodeURI keeps every character that has a structural meaning in a URL (; , / ? : @ & = + $ #), because it assumes they are there on purpose. If a value contains one of them, encode that value in Component mode first.
Should spaces be %20 or +?
Both are common. %20 is valid everywhere in a URL. + means a space only in HTML form data and query strings (application/x-www-form-urlencoded). Tick "Spaces as + (form encoding)" when your backend expects form-style encoding. When decoding, tick it to turn + back into spaces.
Why are ' ( ) ! * not encoded?
encodeURIComponent leaves letters, digits and - _ . ! ~ * ' ( ) unchanged. These are allowed in URLs, but a few systems (some OAuth signature schemes, for example) need them escaped as well. Escape them yourself if your target requires it.
What does "broken percent-escape" mean?
Decoding found a % that is not followed by two hex digits, such as 100% or %zz, or bytes that are not valid UTF-8. Encode a literal percent sign as %25.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close