Skip to content

URL Encoder

Encode text for safe use in URLs using percent-encoding

Make your text URL-safe

URLs have rules. Characters like &, =, ?, /, and # are structural, they mean things. A & separates query parameters. A ? starts the query string. If your data contains those characters and you stuff them into a URL raw, things break in confusing ways.

Percent-encoding fixes this. A space becomes %20. An ampersand becomes %26. A question mark becomes %3F. The browser knows these are literal characters, not URL syntax.

This tool uses encodeURIComponent, the correct function for encoding URL parameter values. It encodes everything except unreserved characters (A-Z, a-z, 0-9, - _ . ! ~ * ' ( )), and it handles Unicode properly.

The common encodings

Space → %20 &%26 =%3D ?%3F /%2F #%23 @%40 +%2B %%25

When you need this

Building query strings. If your search term is “mac & cheese,” the URL needs ?q=mac%20%26%20cheese, not ?q=mac & cheese (which would break the & into a parameter separator).

OAuth redirect URLs. You’re passing a callback URL as a parameter to another URL. The inner URL has to be fully encoded or the outer parser will choke on its slashes and question marks.

API requests. Anything user-provided that goes into a URL path or query string needs encoding. File names with spaces, search queries with special characters, filter values with slashes.

Form data. Browser forms use URL encoding by default for POST data (application/x-www-form-urlencoded).

encodeURI vs encodeURIComponent

JavaScript has two encoding functions and picking the wrong one is a classic bug.

encodeURIComponent (what this tool uses) encodes all special characters. Use it when encoding a parameter value.

encodeURI leaves structural characters like :, /, ?, & alone. Use it when encoding a complete URL where you want the structure preserved.

For most tasks, encoding query values, form data, API parameters, encodeURIComponent is the right choice.

To decode percent-encoded URLs back to readable text, use the URL Decoder.

FAQ

Should I encode the whole URL or just the values?

Just the parameter values, typically. Encoding the entire URL would break the structural delimiters.

Unicode support?

Yes, international characters and emojis are converted to their UTF-8 percent-encoded representation. The euro sign becomes %E2%82%AC.

%20 vs + for spaces?

This tool uses %20, which is universally correct for URL encoding. The + convention is specific to application/x-www-form-urlencoded (HTML form POST data).

Client-side?

Yes, your text stays in your browser.

url encoder percent-encoding query-string web

Related Tools

More in Developer Tools