Quick answer
URL encoding (percent-encoding) replaces characters that are unsafe in a URL with a % followed by two hex digits, so a space becomes %20 and é becomes %C3%A9. In Playxoft's URL encoder, paste your text, pick Encode or Decode, and choose Value for a single query value or Whole URL to keep the link's structure intact.
- Encode and decode
- Value or whole-URL scope
- Form + spaces
- Query parameter table
- Error location
- Copy and download
How to use the URL Encoder and Decoder
- 1Choose Encode to make text URL-safe, or Decode to turn %XX sequences back into text.
- 2Pick Value when encoding a single query value or path segment, or Whole URL when encoding a complete link.
- 3Turn on Spaces as + if the string comes from or goes to an HTML form.
- 4Paste your text. The result updates as you type; copy it, download it, or use it as the next input.
- 5If the input contains a query string, check the decoded parameters in the table below the tool.
What is URL encoding?
A URL may only contain a limited set of ASCII characters. Anything else — spaces, accented letters, emoji, or characters that already mean something in a URL such as & and ? — has to be percent-encoded: converted to its UTF-8 bytes, with each byte written as % plus two hexadecimal digits.
So café au lait becomes caf%C3%A9%20au%20lait: the space is byte 20, and é is the two UTF-8 bytes C3 A9. The rules come from RFC 3986, the standard that defines URL syntax.
Should I encode the value or the whole URL?
Getting this wrong is a common cause of broken links. The answer depends on what you are encoding:
| You are encoding | Use | JavaScript | Leaves alone |
|---|---|---|---|
| One query value, e.g. a search term | Value | encodeURIComponent | A–Z a–z 0–9 - _ . ! ~ * ' ( ) |
| A path segment, e.g. a file name | Value | encodeURIComponent | Same as above |
| A complete URL you want to stay clickable | Whole URL | encodeURI | The above plus ; , / ? : @ & = + $ # |
Encode each value before joining it into the URL. If you encode a value with encodeURI, an & inside it survives and silently splits your parameter in two. If you encode a whole URL with encodeURIComponent, the :// and / get escaped and the link stops working.
Why do some URLs use + instead of %20?
Both mean a space, but in different places. HTML forms submit data as application/x-www-form-urlencoded, which writes spaces as +. Most server frameworks (and URLSearchParams in the browser) decode + as a space in the query string.
In the path part of a URL, though, + is a literal plus sign. When in doubt, use %20: it means a space everywhere. Turn on Spaces as + only when you are matching form submissions.
Which characters need percent-encoding?
| Character | Encoded | Why it needs encoding |
|---|---|---|
| Space | %20 (or + in forms) | Not allowed in URLs |
& | %26 | Separates query parameters |
= | %3D | Separates a key from its value |
? | %3F | Starts the query string |
# | %23 | Starts the fragment |
/ | %2F | Separates path segments |
+ | %2B | Means a space in form data |
% | %25 | Starts every escape sequence |
é | %C3%A9 | Non-ASCII, sent as UTF-8 bytes |
How do I URL-encode a string in code?
Every mainstream language has a built-in, so you rarely need a library:
// JavaScript / TypeScript
const url = `https://example.com/search?q=${encodeURIComponent(query)}`;
new URLSearchParams({ q: query }).toString(); // form-style, spaces as +
# Python
from urllib.parse import quote, urlencode
quote("café au lait") # 'caf%C3%A9%20au%20lait'
urlencode({"q": "café au lait"}) # 'q=caf%C3%A9+au+lait'
// Go
url.QueryEscape("café au lait") // "caf%C3%A9+au+lait"
url.PathEscape("café au lait") // "caf%C3%A9%20au%20lait"
// C#
Uri.EscapeDataString("café au lait") // "caf%C3%A9%20au%20lait"
WebUtility.UrlEncode("café au lait") // "caf%C3%A9+au+lait"Building query strings with URLSearchParams (or your language's equivalent) is safer than gluing strings together, because it encodes every key and value for you.
Frequently asked questions
Last updated by the Playxoft engineering team.