← Back

URL Encoder/Decoder

Encode or decode URL-safe characters

Output

About URL Encoder/Decoder

This tool percent-encodes text using the browser's built-in encodeURIComponent rules (a space becomes %20, a Chinese character becomes a UTF-8 byte sequence such as %E4%BD%A0) and reverses the process with decodeURIComponent. It suits query-string values, path segments, or a garbled link copied from a log. Be aware that it offers only this one rule: there is no structure-preserving mode like encodeURI, no form-style 'space becomes plus' option, and no automatic detection of whether your input is already encoded.

How to use it

  1. Paste your text into the 'Input (supports multiple lines, each processed independently)' box. A sample link is already there when the page opens.
  2. Click 'Encode →' to percent-encode every line, or 'Decode →' to turn every line back into readable text.
  3. The result appears in the read-only 'Output' box. When the output is not empty, a copy button appears at the top right so you can copy everything in one click.
  4. If you edit the input, click a button again; the output does not update by itself. To chain operations, copy the output back into the input yourself.

A worked example

Click 'Encode →' on the default sample, https://example.com/搜索?q=你好 世界, and the actual output is https%3A%2F%2Fexample.com%2F%E6%90%9C%E7%B4%A2%3Fq%3D%E4%BD%A0%E5%A5%BD%20%E4%B8%96%E7%95%8C. Notice that the colon, slashes, question mark and equals sign were escaped too, which tells you this tool is meant for encoding a single parameter value, not a whole link. Another case: a b&c=d/é becomes a%20b%26c%3Dd%2F%C3%A9, where & turns into %26 so it cannot be mistaken for a parameter separator. In the other direction, %E4%BD%A0%E5%A5%BD decodes to 你好 (the Chinese greeting). These outputs come from running the same functions, not from guesswork.

Supported features and known limits

  • Encoding uses encodeURIComponent: letters, digits and - _ . ! ~ * ' ( ) are left alone, and everything else becomes UTF-8 percent sequences, including URL delimiters such as : / ? # & = and +.
  • There is no encodeURI behaviour, so you cannot escape the non-ASCII characters in a full URL while keeping https:// and the question mark intact. Split the link and encode only the values.
  • Spaces become %20, never +. On decoding, + is not turned back into a space either: a+b%20c decodes to 'a+b c'. If you are reading application/x-www-form-urlencoded data, handle plus signs yourself.
  • The input is split on line breaks and each line is processed separately; blank lines stay blank. This is handy for a batch of values, but a single value that spans several lines will be encoded piece by piece.
  • When one line fails, that line's output becomes '[Encoding failed] original' or '[Decoding failed] original' and other lines are unaffected. Decoding usually fails because a percent sequence was truncated (for example %E4%BD is missing its last byte) or contains invalid UTF-8, which the browser reports as URI malformed. Encoding fails only for text with lone surrogate characters, which is rare.
  • Only UTF-8 is supported. Percent sequences from older GBK-encoded systems (for example %C4%E3%BA%C3, which stands for 你好) will usually error or produce garbage, and there is no charset selector.
  • Encoding text that is already encoded turns each % into %25, giving double encoding. Decide which button to press based on where the text came from.

Why can't I open the whole link after encoding it?

Because encodeURIComponent escapes structural characters such as :// and ? as well. It is designed for a small piece of data that goes inside a URL, such as the search term after ?q=. The right approach is to keep the link's structure and encode each parameter value on its own before you assemble the URL.

What if the output says '[Decoding failed]'?

First check the line is complete. Text copied from email, chat or logs can be cut off at the end or carry stray spaces and line breaks. Then confirm the source was UTF-8; sequences in GBK or other charsets cannot be restored here. A line of ordinary text that happens to contain a lone percent sign, such as '50% done', will also fail, and that text does not need decoding in the first place.

What is the difference between + and %20?

In the query part of a URL, systems disagree. Traditional HTML form submissions write a space as a plus sign, while JavaScript's encodeURIComponent and most modern APIs use %20. This tool produces and understands only the %20 form. If your string uses plus signs for spaces, replace them with spaces somewhere else before decoding.

Does it change letter case?

The hexadecimal digits in encoded output are uppercase (for example %E4), which is fixed behaviour of encodeURIComponent. Decoding accepts either case. Ordinary letters and digits are never rewritten.

Privacy and processing

Encoding and decoding happen in your browser. The code only calls the built-in encodeURIComponent and decodeURIComponent, makes no request that sends your input to a server, and keeps no history. Refreshing or closing the page clears what you typed. If you are handling links that carry tokens or passwords, avoid leaving the page open on a shared device.