# utils_convertData

Converts data between different encodings (utf8, hex, base64, binary). Useful for transforming data formats when working with blockchain data, encryption, or file processing.

Parameters:
- data (required): The string to convert
- from (required): Source encoding format (utf8, hex, base64, or binary)
- to (required): Target encoding format (utf8, hex, base64, or binary)

Example usage:
- UTF-8 to hex: {"data": "hello world", "from": "utf8", "to": "hex"} → 68656c6c6f20776f726c64
- UTF-8 to base64: {"data": "Hello World", "from": "utf8", "to": "base64"} → SGVsbG8gV29ybGQ=
- base64 to UTF-8: {"data": "SGVsbG8gV29ybGQ=", "from": "base64", "to": "utf8"} → Hello World
- hex to base64: {"data": "68656c6c6f20776f726c64", "from": "hex", "to": "base64"} → aGVsbG8gd29ybGQ=

Notes:
- All parameters are required
- The tool returns the converted data as a string
- For binary conversion, data is represented as an array of byte values

## Result

The converted value as text; array representations are JSON-encoded.

## Permissions

No spending approval is requested by this handler. Public network lookups can still fail or require a compatible service.

## Definition 1 (full)

Registered in: Before wallet setup; Legacy local wallet; Legacy local identity; Local Vault · broadcasting disabled; Local Vault · all roles; Local Vault · payment role only; Project · payments scope; External BRC-100 wallet; Local Vault + sponsor; Droplit wallet.

Converts data between different encodings (utf8, hex, base64, binary). Useful for transforming data formats when working with blockchain data, encryption, or file processing.

Parameters:
- data (required): The string to convert
- from (required): Source encoding format (utf8, hex, base64, or binary)
- to (required): Target encoding format (utf8, hex, base64, or binary)

Example usage:
- UTF-8 to hex: {"data": "hello world", "from": "utf8", "to": "hex"} → 68656c6c6f20776f726c64
- UTF-8 to base64: {"data": "Hello World", "from": "utf8", "to": "base64"} → SGVsbG8gV29ybGQ=
- base64 to UTF-8: {"data": "SGVsbG8gV29ybGQ=", "from": "base64", "to": "utf8"} → Hello World
- hex to base64: {"data": "68656c6c6f20776f726c64", "from": "hex", "to": "base64"} → aGVsbG8gd29ybGQ=

Notes:
- All parameters are required
- The tool returns the converted data as a string
- For binary conversion, data is represented as an array of byte values

| Field | Type | Required | Description | Constraints |
| --- | --- | --- | --- | --- |
| data | string | Yes | The data string to be converted |  |
| from | "utf8" \| "hex" \| "base64" \| "binary" | Yes | Source encoding format (utf8, hex, base64, or binary) |  |
| to | "utf8" \| "hex" \| "base64" \| "binary" | Yes | Target encoding format to convert to (utf8, hex, base64, or binary) |  |

Nested requirements apply when their parent is supplied.

### Input schema

```json
{
  "type": "object",
  "properties": {
    "data": {
      "type": "string",
      "description": "The data string to be converted"
    },
    "from": {
      "type": "string",
      "enum": [
        "utf8",
        "hex",
        "base64",
        "binary"
      ],
      "description": "Source encoding format (utf8, hex, base64, or binary)"
    },
    "to": {
      "type": "string",
      "enum": [
        "utf8",
        "hex",
        "base64",
        "binary"
      ],
      "description": "Target encoding format to convert to (utf8, hex, base64, or binary)"
    }
  },
  "required": [
    "data",
    "from",
    "to"
  ],
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```

[All tools](https://bsvmcp.com/docs/tools)