URL Encoder & Decoder

Encode or decode URL components — handles special characters, spaces and Unicode safely.

Copied ✓
AdvertisementAd slot #1 · below the result

What percent-encoding is

A URL may only contain a limited set of ASCII characters. Any character outside that safe set — spaces, accented letters, punctuation, or Unicode — must be percent-encoded: replaced by a % followed by two hexadecimal digits representing the byte value. A space becomes %20, a pound sign becomes %23, and so on.

This is not compression or encryption — it is a reversible transformation defined by RFC 3986 that makes any string safe to transmit as part of a URL.

encodeURIComponent vs encodeURI

JavaScript provides two encoding functions and the difference matters:

  • encodeURI encodes a complete URL. It leaves characters that have structural meaning in a URL untouched — /, ?, #, &, =, : — because removing them would break the URL structure.
  • encodeURIComponent encodes a component — a single query value, a path segment, or a fragment. It encodes those same structural characters, because inside a component they are data, not structure.

This tool uses encodeURIComponent, which is almost always what you want. If you are encoding the value of a query parameter — for example the search term in ?q=hello world — you need the component version so the space becomes %20 and does not accidentally split the URL.

Unicode handling

Modern URLs (IRIs) can contain Unicode characters, but the underlying encoding is still bytes. encodeURIComponent converts each Unicode character to its UTF-8 byte sequence first and then percent-encodes each byte. An em dash (U+2014, UTF-8: E2 80 94) becomes %E2%80%94. Decoding reverses the process exactly, so the round-trip is lossless for any valid Unicode text.

Worked example

Encoding hello world produces:

hello%20world

Decoding that result returns hello world exactly.

When decoding fails

Not every string containing % is valid percent-encoding. A sequence like %ZZ is malformed — ZZ is not a valid hexadecimal pair. This tool catches that error and shows a clear message rather than returning garbled text.

Frequently asked

When do I need to encode a URL?

Any time you construct a URL programmatically — building a query string, setting a redirect target, creating a share link — you should encode each value separately with encodeURIComponent before joining the parts together.

Why does a space sometimes appear as + in URLs?

The application/x-www-form-urlencoded format (used by HTML forms) encodes spaces as +. RFC 3986 percent-encoding encodes them as %20. This tool follows RFC 3986, which is correct for modern URLs.

Is my input sent anywhere?

No. Encoding and decoding run entirely in your browser. Nothing you type is transmitted.

AdvertisementAd slot #2 · after the explainer