
URL Encoder / Decoder API
Percent-encode or decode URLs and query values as you type, with component, full-URL and form (+ for spaces) modes, clear errors, and a query-string breakdown.
All API requests require a valid API key passed in the Authorization header as a Bearer token.
120 requests per minute
1 endpoint available
Overview
Percent-encodes or decodes text, and breaks a URL or query string into its parts.
Modes
- component (default) - like
encodeURIComponent. For one value going into a URL, such as a search term or a path segment. Escapes everything except letters, digits and- _ . ! ~ * ' ( ), including/ ? & = #. - uri - like
encodeURI. For a whole URL. Keeps the characters that give a URL its structure and escapes spaces, non-ASCII letters and other unsafe characters. Decoding leaves escaped structure characters such as%2Falone. - form -
application/x-www-form-urlencoded, as HTML forms send it. Spaces become+. Decoding turns+into a space.
Errors
Decoding stops at the first malformed escape and returns a 400 whose message says what is wrong and where.
details.index is the zero-based position of the problem in text. Text with an unpaired
UTF-16 surrogate cannot be encoded and also returns a 400. Percent-encoded bytes are read as UTF-8.
breakdown
breakdown is filled in when the input or the result is an absolute URL (with a scheme and
://) or a query string such as ?a=1&b=2. Otherwise it is null. url
holds the parsed parts and params the query pairs, each with the decoded key and
value and the raw rawKey and rawValue.
Limits
Up to 100,000 characters of text.
Endpoints
https://opentools.ca/api/v1/tools/url-encoder-decoderRequest Body
Content-Type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
| text | string | Required | The text to encode or decode, 1 to 100,000 characters. |
| direction | string Enum: encode, decode | Required | Whether to encode or decode. |
| mode | string Enum: component, uri, form | Optional | Encoding style, described above.Default: component |
Response Example
{
"success": true,
"direction": "encode",
"mode": "uri",
"result": "https://example.com/search?q=caf%C3%A9%20cr%C3%A8me&lang=fr",
"breakdown": {
"url": {
"protocol": "https:",
"username": "",
"password": "",
"hostname": "example.com",
"port": "",
"pathname": "/search",
"hash": "",
"origin": "https://example.com"
},
"params": [
{
"key": "q",
"value": "café crème",
"rawKey": "q",
"rawValue": "caf%C3%A9%20cr%C3%A8me",
"hasValue": true
},
{
"key": "lang",
"value": "fr",
"rawKey": "lang",
"rawValue": "fr",
"hasValue": true
}
]
}
}Error Codes
Code Examples
# Encode a query value
curl -X POST https://opentools.ca/api/v1/tools/url-encoder-decoder \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "café crème & more", "direction": "encode", "mode": "component"}'
# Decode form data
curl -X POST https://opentools.ca/api/v1/tools/url-encoder-decoder \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "a+b%26c", "direction": "decode", "mode": "form"}'Rather use it in your browser? Open the URL Encoder / Decoder