Leadmetrics
Free tool, no sign-up

URL encoder and decoder

Percent-encode text for a URL, or decode it back, with the right rule for where it is going.

For text going inside a URL: a search term, a redirect target, a campaign name. Escapes / ? & = and the rest.

Nothing leaves your browser.

Result

Paste something to convert.

What to know

  • Note: Paste the text or URL to convert.

How to use it

  1. Choose what you are doing: encoding a value, encoding a whole URL, or decoding.
  2. Paste the text.
  3. Copy the result.
  4. If a decode fails, the input contains a stray % — it should have been written as %25.

Two encodings, one common mistake

A redirect target going inside another URL must have its slashes and colon escaped, or the receiving server reads them as its own structure. A whole URL being tidied up must keep them.

Choosing the wrong one gives a link that looks fine and lands somewhere else, which is why this tool makes you say which you meant.

The plus is a trap

In a query string a plus means a space, by a convention inherited from HTML forms. In a path it is a literal plus. The same character, two meanings, decided by position.

If a value may contain a real plus — a phone number, for instance — encode it as %2B and the ambiguity goes away.

A failed decode is information

Decoding throws when it meets a % that is not followed by two hex digits, which means the text contains a literal percent sign that was never encoded.

That is worth knowing rather than working around: something upstream is building URLs by gluing strings together, and this is the first symptom.

Encoding a whole URL is not the same as encoding a value

encodeURI leaves the structural characters alone so a complete address stays usable. encodeURIComponent escapes them too, which is what you want for a single parameter value. Use the first on a URL and the second on anything you are putting inside one.

If you see %253A in a link, that is double encoding — a percent sign that was itself encoded. It means a value was escaped twice on its way through two systems.

URL encoder and decoder FAQ

What is the difference between encoding a value and a whole URL?

Encoding a value escapes the characters that structure a URL, so / : ? & = all become escapes. Encoding a whole URL leaves those alone, because they are doing their job, and escapes only what would break it, such as spaces.

Why does + sometimes mean a space?

It is a form-submission convention that survived into query strings. In a query string a plus decodes to a space; in a path it is a literal plus. A plus that must stay a plus has to be written %2B.

Why does my URL have %2520 in it?

It was encoded twice: a space became %20, then the % became %25, giving %2520. Decode it twice to get back the original, then fix whichever step is encoding an already-encoded value.

Which characters never need encoding?

The unreserved set: letters, digits, hyphen, full stop, underscore and tilde. Everything else either has a structural meaning in a URL or is outside ASCII, and both cases need escaping when they appear inside a value.

How are accented or non-Latin characters encoded?

As their UTF-8 bytes, each written as a percent escape — é becomes %C3%A9, which is two bytes and six characters. This is why an encoded non-English URL looks so much longer than the original, and why decoding with the wrong character set produces mojibake rather than an error.

Is this the same as encodeURIComponent?

Almost. The JavaScript function leaves a handful of characters unescaped — the apostrophe, brackets, exclamation mark and asterisk — which are legal in a query string and occasionally a problem elsewhere. For ordinary web use the difference never matters.

Should I encode before or after building the URL?

Encode each value, then assemble. Encoding the finished URL escapes the separators that make it a URL, and that single mistake is the cause of most of the double-encoded addresses you will ever debug.

What about the fragment after the hash?

A literal hash inside a value must be %23 or everything after it is read as the fragment and never reaches the server. The fragment itself has slightly looser rules, but encoding it the same way as a value is always safe.

Why does an email address break when I put it in a link?

The plus sign. Addresses of the form name+tag@example.com are common, and in a query string a plus decodes to a space, so the address arrives mangled. It has to be written %2B.

Is it safe to decode something twice?

Only if you know it was encoded twice. Decoding a correctly encoded string a second time can turn a legitimate %2520 into a space and silently corrupt the value. Decode once, look at the result, and decode again only if it still contains escapes.