# URL encoder and decoder

Percent-encode text for use in a URL, or decode it. Works on one value or a whole URL.

- Endpoint: `POST https://setget.net/v1/tools/url-encode` with JSON `{"input": {...}}`
- MCP: `run_tool` with `slug` = `url-encode`
- Page: https://setget.net/tools/url-encode

## Inputs

- `text` (required, string): The text or URL to encode or decode.
- `action` (optional, string, one of `encode`, `decode`, default `"encode"`): Encode to percent-escapes, or decode them.
- `mode` (optional, string, one of `component`, `full`, default `"component"`): "component" treats the text as one value and escapes every reserved character. "full" treats it as a whole URL and keeps : / ? & = # in place.
- `plus_for_space` (optional, boolean, default `false`): Treat "+" as a space when decoding, and write spaces as "+" when encoding, as HTML forms do.

## Example 1

```json
{"input":{"text":"hello world & more/stuff?"}}
```

Result:

```json
{"text":"hello%20world%20%26%20more%2Fstuff%3F"}
```

## Example 2: A whole URL keeps its structure

```json
{"input":{"text":"https://example.com/café menu?q=a b&lang=en","mode":"full"}}
```

Result:

```json
{"text":"https://example.com/caf%C3%A9%20menu?q=a%20b&lang=en"}
```

## Example 3: Decoding form data

```json
{"input":{"text":"q=caf%C3%A9+au+lait%21","action":"decode","plus_for_space":true}}
```

Result:

```json
{"text":"q=café au lait!","invalid_utf8":false}
```

**Should I use component or full?** Use "component" for a single value you are putting into a URL, such as a search term. Use "full" when you have a complete URL and only want unsafe characters such as spaces fixed.

**When is "+" a space?** Only in form data and query strings written by HTML forms. Elsewhere "+" is a literal plus, so the option is off by default.

**Does full mode encode a URL twice?** No. Escapes that are already there, such as %20, are left alone. A stray "%" becomes %25.
