@tpmjs/tools-yaml-parse
Parse YAML text into JavaScript objects. Handles various YAML formats including objects, arrays, and scalars. Returns parsed data with validation status.
Test @tpmjs/tools-yaml-parse (yamlParseTool) with AI-powered execution
0/2000 characters
Install this tool and use it with the AI SDK
npm install @tpmjs/tools-yaml-parsepnpm add @tpmjs/tools-yaml-parseyarn add @tpmjs/tools-yaml-parsebun add @tpmjs/tools-yaml-parsedeno add npm:@tpmjs/tools-yaml-parseimport { yamlParseTool } from '@tpmjs/tools-yaml-parse';import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { yamlParseTool } from '@tpmjs/tools-yaml-parse';
const result = await generateText({
model: openai('gpt-4o'),
tools: { yamlParseTool },
prompt: 'Your prompt here...',
});
console.log(result.text);Available configuration options
yamlstringThe YAML string to parse
Schema extracted: 1/1/2026, 8:18:26 AM
Parse YAML text into JavaScript objects with validation and error handling.
npm install @tpmjs/tools-yaml-parse
import { yamlParseTool } from '@tpmjs/tools-yaml-parse'; // Use with AI SDK const result = await yamlParseTool.execute({ yaml: ` name: John Doe age: 30 hobbies: - reading - coding - hiking ` }); console.log(result); // { // data: { name: 'John Doe', age: 30, hobbies: ['reading', 'coding', 'hiking'] }, // isValid: true, // metadata: { type: 'object', size: 3 } // }
js-yaml library for full YAML 1.2 support| Parameter | Type | Required | Description |
|---|---|---|---|
| yaml | string | Yes | The YAML string to parse |
interface YamlParseResult { data: unknown; // The parsed JavaScript object/value isValid: boolean; // Whether parsing was successful error?: string; // Error message if parsing failed metadata?: { type: string; // Type of parsed data (object, array, string, etc.) size: number; // Number of keys (objects) or items (arrays) }; }
const result = await yamlParseTool.execute({ yaml: 'name: Alice\nage: 25' }); // { data: { name: 'Alice', age: 25 }, isValid: true, ... }
const result = await yamlParseTool.execute({ yaml: '- apple\n- banana\n- cherry' }); // { data: ['apple', 'banana', 'cherry'], isValid: true, metadata: { type: 'array', size: 3 } }
const result = await yamlParseTool.execute({ yaml: 'invalid: yaml: syntax:' }); // { data: null, isValid: false, error: 'bad indentation...' }
MIT
Downloads/month
0
Quality Score