"category": "dev-utility",

URL Encoder

"tldr": Paste text and get it percent-encoded for safe use in URLs - spaces, &, ?, and unicode handled correctly.

Percent-encode text so it can travel safely inside a URL: spaces become %20, & becomes %26, and non-ASCII characters are UTF-8 encoded byte by byte (é becomes %C3%A9). The output matches JavaScript's encodeURIComponent - the strict encoding correct for query-parameter values.

{"text": "url-encoded"}

Un-encoded special characters are a classic bug source: an & inside a parameter value silently splits it into two parameters, a # truncates everything after it, and a + may or may not become a space depending on the server. Encoding values before assembling URLs eliminates the whole class.

How to URL-encode text

  1. 1Paste the raw text - typically a query-parameter value.
  2. 2Every character unsafe in URLs is converted to %XX percent-encoding.
  3. 3Unicode is encoded as UTF-8 bytes, the standard all modern servers expect.
  4. 4Paste the result into your URL after the = of the parameter.

Convert Text to URL-encoded in code

JavaScript
const url = `/search?q=${encodeURIComponent(query)}`;
// or let URLSearchParams do it:
const params = new URLSearchParams({ q: query }).toString();
Python
from urllib.parse import quote, urlencode

quote("coffee & cream")            # 'coffee%20%26%20cream'
urlencode({"q": "coffee & cream"}) # 'q=coffee+%26+cream'

Frequently asked questions

Should I encode the whole URL or just the values?

Just the parts that are data: parameter values and dynamic path segments. Encoding the whole URL turns the structural characters (:, /, ?, &) into literals and breaks it - the equivalent of JavaScript's encodeURI vs encodeURIComponent distinction. This tool is the strict, per-value variant.

Space: %20 or +?

%20 is always correct. + means space only in the application/x-www-form-urlencoded convention (HTML form bodies and, historically, query strings) - in a path segment a + is a literal plus. Emitting %20 everywhere is the unambiguous choice.

Why is my value double-encoded (%2520)?

%2520 is %20 encoded again - the % became %25. It happens when two layers both encode (your code and an HTTP library). Encode exactly once, at the point where you assemble the URL, and pass raw values everywhere else.

Last updated:

You might also need

Free and in-browser, like everything on JSON Console. Browse all tools →