@tpmjs/tools-yaml-stringify
Convert JavaScript objects to YAML strings. Supports objects, arrays, and primitive values with configurable indentation. Perfect for generating configuration files or serializing data.
Test @tpmjs/tools-yaml-stringify (yamlStringifyTool) with AI-powered execution
0/2000 characters
Install this tool and use it with the AI SDK
npm install @tpmjs/tools-yaml-stringifypnpm add @tpmjs/tools-yaml-stringifyyarn add @tpmjs/tools-yaml-stringifybun add @tpmjs/tools-yaml-stringifydeno add npm:@tpmjs/tools-yaml-stringifyimport { yamlStringifyTool } from '@tpmjs/tools-yaml-stringify';import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { yamlStringifyTool } from '@tpmjs/tools-yaml-stringify';
const result = await generateText({
model: openai('gpt-4o'),
tools: { yamlStringifyTool },
prompt: 'Your prompt here...',
});
console.log(result.text);Available configuration options
dataobjectarraystringnumberbooleannullThe JavaScript data to convert to YAML
indentnumberNumber of spaces for indentation (default: 2, range: 1-8)
Schema extracted: 1/1/2026, 8:18:05 AM
Convert JavaScript objects to YAML strings with formatting options.
npm install @tpmjs/tools-yaml-stringify
import { yamlStringifyTool } from '@tpmjs/tools-yaml-stringify'; // Use with AI SDK const result = await yamlStringifyTool.execute({ data: { name: 'John Doe', age: 30, hobbies: ['reading', 'coding', 'hiking'] }, indent: 2 }); console.log(result.yaml); // name: John Doe // age: 30 // hobbies: // - reading // - coding // - hiking
js-yaml library for YAML 1.2 output| Parameter | Type | Required | Description |
|---|---|---|---|
| data | any | Yes | The JavaScript data to convert to YAML |
| indent | number | No | Spaces for indentation (default: 2, range: 1-8) |
interface YamlStringifyResult { yaml: string; // The YAML string output metadata: { lines: number; // Number of lines in the output characters: number; // Total character count indent: number; // Indentation level used }; }
const result = await yamlStringifyTool.execute({ data: { name: 'Alice', role: 'Developer' } }); console.log(result.yaml); // name: Alice // role: Developer
const result = await yamlStringifyTool.execute({ data: ['apple', 'banana', 'cherry'], indent: 4 }); console.log(result.yaml); // - apple // - banana // - cherry
const result = await yamlStringifyTool.execute({ data: { server: { host: 'localhost', port: 8080, options: { ssl: true, timeout: 3000 } } } }); console.log(result.yaml); // server: // host: localhost // port: 8080 // options: // ssl: true // timeout: 3000
const result = await yamlStringifyTool.execute({ data: { config: { debug: true } } }); console.log(result.metadata); // { lines: 2, characters: 25, indent: 2 }
MIT
Downloads/month
0
Quality Score