Introduction
Convert Buddy is a high-performance, streaming-first data conversion library powered by Rust and WebAssembly. It transforms data between CSV, JSON, NDJSON, and XML formats with deterministic memory usage and real-time performance telemetry.
Interactive example
Live sandbox demonstrating the streaming API. All examples use `stream()` and show batch processing, progress, and optional `done` stats.
Code Sandbox
import { ConvertBuddy } from 'convert-buddy-js';
(async () => {
const csv = 'name,age,city\nAlice,30,NYC\nBob,25,LA\nCarol,35,SF';
const buddy = new ConvertBuddy({ outputFormat: 'ndjson' });
// Process records in small batches and log progress
const controller = buddy.stream(csv, {
recordBatchSize: 2,
onRecords: async (ctrl, records, stats, total) => {
console.log('Batch received:', records);
// simulate async work
await new Promise(r => setTimeout(r, 50));
// Report progress from onRecords (preferred)
console.log('Progress: ' + ctrl.recordCount + ' records, ' + stats.throughputMbPerSec.toFixed(2) + ' MB/s');
},
onDone: (final) => console.log('Done:', final),
profile: true
});
// Optional: await final stats
const final = await controller.done;
console.log('Final stats:', final);
})();Terminal
Waiting for output...- NDJSON: Newline-delimited JSON (one object per line)
- XML: Configurable record elements, attributes support