@tpmjs/official-base64-encode
Encode string or buffer to base64 format. Supports utf8 (default), binary, and hex character encodings. Returns the base64 encoded string and the byte length of the original data.
Test @tpmjs/official-base64-encode (base64EncodeTool) with AI-powered execution
0/2000 characters
Install this tool and use it with the AI SDK
npm install @tpmjs/official-base64-encodepnpm add @tpmjs/official-base64-encodeyarn add @tpmjs/official-base64-encodebun add @tpmjs/official-base64-encodedeno add npm:@tpmjs/official-base64-encodeimport { base64EncodeTool } from '@tpmjs/official-base64-encode';import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { base64EncodeTool } from '@tpmjs/official-base64-encode';
const result = await generateText({
model: openai('gpt-4o'),
tools: { base64EncodeTool },
prompt: 'Your prompt here...',
});
console.log(result.text);Available configuration options
datastringThe data to encode to base64
encodingstringCharacter encoding of the input data (default: utf8)
Schema extracted: 1/1/2026, 8:18:33 AM
Encode string or buffer to base64 format with support for multiple character encodings.
npm install @tpmjs/official-base64-encode
import { base64EncodeTool } from '@tpmjs/official-base64-encode'; import { generateText } from 'ai'; const result = await generateText({ model: yourModel, tools: { base64Encode: base64EncodeTool, }, prompt: 'Encode "Hello, World!" to base64', });
data (string, required): The data to encode to base64encoding (string, optional): Character encoding of the input data
'utf8' (default), 'binary', 'hex'{ base64: string; // The base64 encoded string byteLength: number; // The byte length of the original data }
const result = await base64EncodeTool.execute({ data: 'Hello, World!', }); // { base64: 'SGVsbG8sIFdvcmxkIQ==', byteLength: 13 }
const result = await base64EncodeTool.execute({ data: '\x00\x01\x02\x03', encoding: 'binary', }); // { base64: 'AAECAw==', byteLength: 4 }
const result = await base64EncodeTool.execute({ data: 'deadbeef', encoding: 'hex', }); // { base64: '3q2+7w==', byteLength: 4 }
MIT
Downloads/month
0
Quality Score