# Base64 encoder and decoder

Encode text to Base64 or decode it back, in the standard or URL-safe alphabet.

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

## Inputs

- `text` (required, string): The text to encode, or the Base64 to decode.
- `action` (optional, string, one of `encode`, `decode`, default `"encode"`): Encode text to Base64, or decode Base64 to text.
- `variant` (optional, string, one of `standard`, `url-safe`, default `"standard"`): Alphabet for encoding. "url-safe" uses - and _ in place of + and /. Decoding accepts both.
- `padding` (optional, boolean, default `true`): Keep the trailing "=" padding when encoding.

## Example 1

```json
{"input":{"text":"Hello, World!"}}
```

Result:

```json
{"text":"SGVsbG8sIFdvcmxkIQ==","bytes":13}
```

## Example 2: Decoding without padding

```json
{"input":{"text":"SGVsbG8sIFdvcmxkIQ","action":"decode"}}
```

Result:

```json
{"text":"Hello, World!","encoding":"utf-8","binary":false,"bytes":13}
```

## Example 3: URL-safe, no padding

```json
{"input":{"text":"subjects?_d=1","variant":"url-safe","padding":false}}
```

Result:

```json
{"text":"c3ViamVjdHM_X2Q9MQ","bytes":13}
```

**Is Base64 encryption?** No. Anyone can decode it. Base64 only makes data safe to carry as text; it hides nothing.

**What if the decoded data is not text?** Bytes that are not valid UTF-8 are returned as hex, with "binary" set to true.

**Do I need the "=" signs to decode?** No. Missing padding, line breaks and spaces are all accepted.
