@tpmjs/official-base64-decode
Decode base64 encoded data to string. Supports utf8 (default), binary, and hex output encodings. Returns the decoded string and the byte length of the decoded data.
Test @tpmjs/official-base64-decode (base64DecodeTool) with AI-powered execution
0/2000 characters
Install this tool and use it with the AI SDK
npm install @tpmjs/official-base64-decodepnpm add @tpmjs/official-base64-decodeyarn add @tpmjs/official-base64-decodebun add @tpmjs/official-base64-decodedeno add npm:@tpmjs/official-base64-decodeimport { base64DecodeTool } from '@tpmjs/official-base64-decode';import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { base64DecodeTool } from '@tpmjs/official-base64-decode';
const result = await generateText({
model: openai('gpt-4o'),
tools: { base64DecodeTool },
prompt: 'Your prompt here...',
});
console.log(result.text);Available configuration options
base64stringThe base64 encoded data to decode
encodingstringCharacter encoding for the output data (default: utf8)
Schema extracted: 1/1/2026, 8:17:40 AM
Decode base64 encoded data to string with support for multiple output encodings.
npm install @tpmjs/official-base64-decode
import { base64DecodeTool } from '@tpmjs/official-base64-decode'; import { generateText } from 'ai'; const result = await generateText({ model: yourModel, tools: { base64Decode: base64DecodeTool, }, prompt: 'Decode the base64 string "SGVsbG8sIFdvcmxkIQ=="', });
base64 (string, required): The base64 encoded data to decodeencoding (string, optional): Character encoding for the output data
'utf8' (default), 'binary', 'hex'{ decoded: string; // The decoded string byteLength: number; // The byte length of the decoded data }
const result = await base64DecodeTool.execute({ base64: 'SGVsbG8sIFdvcmxkIQ==', }); // { decoded: 'Hello, World!', byteLength: 13 }
const result = await base64DecodeTool.execute({ base64: '3q2+7w==', encoding: 'hex', }); // { decoded: 'deadbeef', byteLength: 4 }
const result = await base64DecodeTool.execute({ base64: 'AAECAw==', encoding: 'binary', }); // { decoded: '\x00\x01\x02\x03', byteLength: 4 }
The tool throws an error if:
MIT
Downloads/month
0
Quality Score