How to use the URL Encoder & Decoder
- Choose Encode or Decode.
- Pick how to encode: a single value (component), a whole URL, or a form value with β+β for spaces.
- Type or paste text. The result updates as you type.
- When the text is a full URL, its scheme, host, path and every query parameter are listed below.
Why URLs need encoding
A URL can only contain a limited set of characters, and some of them have jobs: ? starts the query, & separates parameters and = separates a name from its value. To send a value that contains these characters, or spaces and non-English letters, each unsafe byte is written as % followed by two hexadecimal digits. A space becomes %20, and Γ© becomes %C3%A9.
Which mode to use
- Component: for one value going into a URL, such as a search term or a record name. Encodes everything except letters, digits and
-_.!~*'(). - Whole URL: for a complete address that may contain spaces. Leaves
:/?#&=alone so the URL keeps its structure. - Form: for
application/x-www-form-urlencodedbodies and Apex. Spaces become+.
URL encoding in Apex
String q = EncodingUtil.urlEncode('Acme & Sons', 'UTF-8'); // Acme+%26+Sons
req.setEndpoint('callout:Search_API/accounts?name=' + q);
String original = EncodingUtil.urlDecode(q, 'UTF-8'); // Acme & SonsEncode each value separately, never the whole URL: encoding the whole URL would also encode the ? and & that give it structure.
Features and limitations
What it does
- Three encodings:
encodeURIComponent,encodeURIandapplication/x-www-form-urlencoded. - Form mode produces exactly what Apex
EncodingUtil.urlEncode(value, 'UTF-8')returns. - Decoding explains malformed percent-sequences and where they are.
- Breaks any URL into its parts and decodes every query parameter, including repeated ones.
- Full UTF-8 support for accented letters, other alphabets and emoji.
What it does not do
- Encoding is not encryption; anyone can decode the result.
- It does not shorten URLs or check whether they work.
- Internationalised domain names are shown as the browser parses them, which may be in punycode.