A TOML formatter library.
This library provides TOML formatting capabilities while preserving comments, whitespace, and the original document structure where appropriate.
- Format TOML documents according to configurable style options
- Preserve comments and meaningful whitespace
- Handle syntax errors gracefully
- Fault-tolerant parsing using Rowan syntax trees
use oxc_toml::{format, Options};
const SOURCE: &str = "value=1\n[table]\nstring='some string'";
let formatted = format(SOURCE, Options::default());Format all TOML files in a directory:
cargo run --example format_directory [PATH]This example uses the ignore crate to walk a directory tree and format all TOML files, respecting .gitignore and other ignore files.
This project is a formatter-only fork of the excellent Taplo project, originally created by Ferenc Tamás.
This fork strips away all non-formatter components from Taplo, including:
- CLI tool
- Language Server Protocol (LSP) implementation
- WebAssembly bindings
- DOM (Document Object Model) for TOML manipulation
- JavaScript/TypeScript packages
- Editor integrations
The result is a focused, lightweight library that does one thing well: format TOML documents.
Taplo is a comprehensive TOML toolkit that provides:
- TOML v1.0.0 parser
- Formatter (the foundation of this fork)
- Language server for IDE integration
- CLI tool for formatting and validation
- WebAssembly bindings for browser/Node.js
- Schema validation
If you need these features, please use the original Taplo project.
This project maintains the original MIT License from Taplo. See LICENSE for details.