Skip to main content
Glama

text-to-binary

Convert text to binary code or decode binary back to text using this IT tool. Ideal for encoding messages, data processing, or understanding binary representations.

Instructions

Convert text to binary and vice versa

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYesText to convert to binary, or binary to convert to text
operationYesOperation: encode text to binary or decode binary to text

Implementation Reference

  • Registration of the "convert_text_to_binary" tool (matches text-to-binary functionality) via exported register function called dynamically from src/index.ts
    export function registerConvertTextBinary(server: McpServer) { server.registerTool("convert_text_to_binary", { description: "Convert text to binary and vice versa", inputSchema: { input: z.string().describe("Text to convert to binary, or binary to convert to text"), operation: z.enum(["encode", "decode"]).describe("Operation: encode text to binary or decode binary to text"), }, // VS Code compliance annotations annotations: { title: "Convert Text To Binary", description: "Convert text to binary and vice versa", readOnlyHint: false } }, async ({ input, operation }) => { try { if (operation === "encode") { const binary = input .split('') .map(char => char.charCodeAt(0).toString(2).padStart(8, '0')) .join(' '); return { content: [ { type: "text", text: `Text: ${input} Binary: ${binary}`, }, ], }; } else { // Decode binary to text const binaryGroups = input.replace(/\s+/g, ' ').trim().split(' '); const text = binaryGroups .map(binary => String.fromCharCode(parseInt(binary, 2))) .join(''); return { content: [ { type: "text", text: `Binary: ${input} Text: ${text}`, }, ], }; } } catch (error) { return { content: [ { type: "text", text: `Error converting text/binary: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } } ); }
  • Handler function implementing text to binary encoding (splits chars to 8-bit binary strings separated by space) and binary to text decoding.
    }, async ({ input, operation }) => { try { if (operation === "encode") { const binary = input .split('') .map(char => char.charCodeAt(0).toString(2).padStart(8, '0')) .join(' '); return { content: [ { type: "text", text: `Text: ${input} Binary: ${binary}`, }, ], }; } else { // Decode binary to text const binaryGroups = input.replace(/\s+/g, ' ').trim().split(' '); const text = binaryGroups .map(binary => String.fromCharCode(parseInt(binary, 2))) .join(''); return { content: [ { type: "text", text: `Binary: ${input} Text: ${text}`, }, ], }; } } catch (error) { return { content: [ { type: "text", text: `Error converting text/binary: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } }
  • Zod input schema for the tool: 'input' (string) and 'operation' (enum: encode/decode).
    inputSchema: { input: z.string().describe("Text to convert to binary, or binary to convert to text"), operation: z.enum(["encode", "decode"]).describe("Operation: encode text to binary or decode binary to text"), },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/wrenchpilot/it-tools-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server