Multi-format converter (JSON/TOON/CSV/YAML) with smart format selection and auto-detection
npm install @programsmagic/toon-converterMulti-format converter (JSON/TOON/CSV/YAML) with smart format selection and auto-detection.
``bash`
npm install @toon/converteror
pnpm add @toon/converteror
yarn add @toon/converter
`typescript
import { convert } from '@toon/converter';
const json = JSON.stringify({ user: { id: 123, name: 'Ada' } });
const result = convert(json, {
from: 'json',
to: 'toon',
});
console.log(result.content);
console.log(result.metadata.tokenSavings); // Token savings percentage
`
`typescript
import { convertFile } from '@toon/converter';
const result = convertFile(content, 'data.json', {
to: 'toon',
// from is auto-detected from filename and content
});
`
`typescript
import { selectOptimalFormat } from '@toon/converter';
const data = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
const selection = selectOptimalFormat(data);
console.log(selection.recommended); // 'csv' or 'toon'
`
`typescript
import { batchConvert } from '@toon/converter';
const result = await batchConvert(
[
{ input: 'data1.json' },
{ input: 'data2.json', output: 'data2.toon' },
],
{ to: 'toon' }
);
console.log(result.summary);
``
Convert between formats.
Convert with auto-detection from filename.
Auto-detect format from filename and content.
Select optimal format for data structure.
Compare all formats and show savings.
MIT