@polyconv/toml
v0.1.1
Published
TypeScript TOML to JSON converter utilities for Polyconv with pretty output and sorted keys.
Maintainers
Readme
@polyconv/toml
TOML to JSON conversion utilities for Polyconv. Convert TOML strings to JSON from TypeScript with optional pretty output and recursive key sorting.
Installation
pnpm add @polyconv/tomlThis package is ESM-only and requires Node.js 22+.
Features
- Convert TOML strings to JSON
- Optional pretty output and recursive key sorting
- Tree-shakeable exports
- Full TypeScript support
Usage
import { tomlToJson, TomlToJsonConverter } from "@polyconv/toml";
const toml = 'name = "polyconv"\n\n[config]\nenabled = true\n';
const json = tomlToJson(toml, {
pretty: true,
sortKeys: true,
});
const converter = new TomlToJsonConverter();
const result = converter.convert(toml);
console.log(result.data);
console.log(result.format); // "json"API
tomlToJson(input: string, options?: TomlToJsonOptions): string
interface TomlToJsonOptions {
pretty?: boolean;
indent?: number;
sortKeys?: boolean; // Sort object keys (default: false)
}Input Contract
tomlToJson accepts TOML as a string. Empty input and invalid TOML throw ConversionError.
License
MIT
