URL Encode/Decode

Encode or decode special characters in URLs for safe transmission.

URLs can only contain a limited set of characters. Anything outside that set - spaces, &, #, non-English characters - needs to be percent-encoded first. Paste your text or URL above to encode or decode it instantly.

How URL Encoding Works

URL encoding (officially called percent-encoding) replaces unsafe characters with a % sign followed by two hex digits. A space becomes %20. An ampersand becomes %26. A question mark becomes %3F. This makes sure URLs work correctly across every browser and server without any characters being misinterpreted.

Characters That Must Be Encoded

  • Spaces - become %20 (or + in form submissions)
  • Reserved characters - ! # $ & ' ( ) * + , / : ; = ? @ [ ] all have special meaning in URLs
  • Non-ASCII characters - accented letters, Chinese characters, emojis and everything outside basic ASCII
  • The percent sign itself - % becomes %25 (otherwise it looks like the start of an encoded sequence)

The %20 vs + Question

This confuses a lot of people. In URL paths, spaces should always be %20. In HTML form data (application/x-www-form-urlencoded), the + sign represents a space. Most web frameworks handle this automatically, but if you're building URLs manually, stick with %20 since it works everywhere.

Watch Out for Double Encoding

Double encoding is one of the most common bugs in web development. It happens when you encode a string that's already been encoded. So %20 becomes %2520 because the % gets encoded again to %25. The fix is simple: only encode your data once, right before you put it in a URL. Never encode a full URL that already contains encoded characters.

encodeURI vs encodeURIComponent in JavaScript

These two functions confuse every JS developer at some point. encodeURI is for encoding a complete URL. It leaves characters like / : ? # alone because they're structural parts of a URL. encodeURIComponent is for encoding a single value that goes inside a URL, like a query parameter. It encodes everything except letters, numbers and a few special chars (- _ . ~). When in doubt, use encodeURIComponent for values and encodeURI for whole URLs.

How to Use

  1. Paste your text or URL into the input area.
  2. Click Encode to convert special characters to percent-encoded format.
  3. Click Decode to turn percent-encoded strings back into readable text.
  4. Copy the result.

Frequently Asked Questions

What's the difference between encodeURI and encodeURIComponent?

encodeURI encodes a full URL but leaves structural characters (like / and ?) alone. encodeURIComponent encodes everything, making it safe for individual values inside query parameters. Use encodeURIComponent when encoding a value, encodeURI when encoding a whole URL.

Should spaces be %20 or +?

In URL paths and normal query values, %20 is the safer default. The + sign for spaces mainly applies to HTML form submissions using application/x-www-form-urlencoded.

What is double encoding and how do I avoid it?

Double encoding happens when you encode an already-encoded string. For example, %20 becomes %2520. To avoid it, only encode your data once and do it right before inserting it into a URL. Never re-encode a URL that already has percent-encoded characters.

Do I need to encode non-English characters in URLs?

They need percent-encoding, yes. Characters like Chinese, Arabic or accented letters travel as UTF-8 byte sequences under the hood. Modern browsers display them nicely in the address bar, but the encoded form is what actually goes over the wire.

Why does my URL break when it contains an & or # symbol?

Because & separates query parameters and # marks a fragment identifier. If your actual data contains these characters, they must be encoded (%26 for & and %23 for #) so the browser doesn't misinterpret them as URL structure.