Plain Text

Percent-Encoded

What is the URL Encoder?

Put a customer name like Ingrid Holm (ops) into a query string unescaped and the space ends the value early. Type the raw text and you get it back escaped by encodeURIComponent: that name becomes Ingrid%20Holm%20(ops). Notice the brackets survive. The function leaves letters, digits and - _ . ! ~ * ' ( ) alone and escapes everything else, which is what you want for one query value or one path segment, not for a whole URL.

There are two encoding flavours and the difference matters. encodeURIComponent (this page) escapes everything special including ?, #, &, =, and /, because at the value-level those characters would change what the URL means. encodeURI is more permissive and leaves those structural characters alone, because it expects you to be encoding a whole already-formed URL. MDN spells out the table of reserved characters if you need the gory details. If you are building a whole URL from parts, the URL Builder is what you want, not this page.

Under RFC 3986 §2.1, an escaped character is written as its UTF-8 bytes, each one as % plus two hex digits. A rocket emoji is four bytes, so it turns into %F0%9F%9A%80, while an ! is left as it is. The WHATWG URL Standard is how browsers apply this today, and Wikipedia's percent-encoding article has a table for checking a code by hand. One thing to watch: the input is not trimmed, so a trailing newline from a copy comes out as %0A at the end. The encoding runs in this tab and the text is not sent anywhere.

How to Use the URL Encoder

Three steps. There is no Convert button; the page updates as you type.

1

Paste your string or click Sample

Type the value on the left, paste it, or press Upload to read a .txt file. Sample gives you a promo line with a double space, an ampersand, a question mark, an email address and a percent sign, which between them cover most of what breaks query strings:

Ava Chen & friends? [email protected]  100% off!

Unicode and emoji work fine. The encoder uses UTF-8 byte sequences, so a Japanese name or an emoji will encode to a multi-byte percent sequence and round-trip cleanly through any standards-compliant decoder.

2

Read the encoded output

The right panel shows the percent-encoded version. Spaces become %20, & becomes %26, ? becomes %3F, @ becomes %40, % itself becomes %25. Updates as you type.

3

Copy or download

For the sample, the right panel reads Ava%20Chen%20%26%20friends%3F%20customer%40shop.com%20%20100%25%20off!, ready to drop after ?promo=. Copy takes that single line, Download stores it as url-encoded.txt, and Clear resets both panels. Got an escaped string to read instead? The URL Decoder reverses it.

When You'd Actually Use This

Building a query string value by hand

Need to construct ?customer=Ava%20Chen&status=active for a quick curl test or a deep link? Encode each value here and paste it into your URL. Forgetting to encode a value with an & in it (a customer name like "Smith & Co.") is a classic source of mysterious "the API only sees half of my parameter" bugs.

Encoding a redirect target

OAuth flows and SSO redirects pass the destination URL inside a query parameter (e.g. ?return_to=...). That destination URL itself contains :, /, ? and &, every one of which has to be percent-encoded so the outer URL stays well-formed. RFC 6749 §3.1.2 calls this out explicitly for OAuth redirect URIs.

Encoding a path segment with a slash in it

If your REST API has routes like /repos/:owner/:name and the name happens to contain a forward slash (rare but legal in some catalogs), the slash has to encode to %2F or the router will treat it as a path separator. Same logic for filenames with spaces or accents in download URLs.

Sanitizing user input before it touches a URL

Any string going into a URL from an HTML form, a search box, or a CSV import needs to be encoded. Unencoded user input is how you end up with broken links, opening parameter injection vectors, or URLs that work for ASCII users and silently fail for everyone else. OWASP's notes on path traversal are a good reminder of what skipping this step costs.

Common Questions

Should I use encodeURIComponent or encodeURI?

Almost always encodeURIComponent, which is what this page uses. It is the right choice for query parameter values, path segments, and anywhere a string needs to be a "piece" of a URL. encodeURI is for encoding a URL that is already structurally complete (rare in practice, since you are usually building from parts). The MDN reference linked above has the full table of which characters each one escapes.

Why is + sometimes used for spaces and sometimes %20?

Two encoding traditions live side by side. application/x-www-form-urlencoded (the ?key=value body of an HTML form submit) uses + for space. The general URL percent-encoding from RFC 3986 uses %20. encodeURIComponent always produces %20. Most servers accept either, but if your downstream decoder is form-strict, swap with .replace(/%20/g, "+") after encoding.

Does it handle emoji and non-ASCII text correctly?

Yes. The encoder serializes the input as UTF-8 first, then percent-encodes each byte. So an emoji becomes a multi-byte percent sequence, and any standards-compliant decoder will round-trip it back. If you are integrating with a system that uses Latin-1 or another legacy encoding, you have a different problem. Change the upstream system; do not hand-roll a non-UTF-8 encoder.

What characters does encodeURIComponent NOT encode?

Letters A-Z and a-z, digits 0-9, and the unreserved characters - _ . ! ~ * ' ( ). Everything else gets percent-encoded. The list comes straight from the original spec and is fixed across every modern JavaScript engine. See the ECMAScript spec for encodeURIComponent if you want chapter and verse.

Is the input I paste here sent anywhere?

No. Encoding runs entirely in your browser via the JavaScript engine. There is no network call, no server, no log. Paste secrets, tokens, anything sensitive. None of it leaves your machine.

How big a string can I encode here?

There is a 256 KB cap on the input. Real-world URL values are kilobytes at most. If you need to encode several MB of data, you are almost certainly trying to embed a payload in a URL when you should be POSTing a body. Encode it server-side and skip the round trip.

Other URL & Encoding Tools

Encoding is one operation. Here's what else pairs naturally with it: