Mock TOML Generator
TOML is the configuration format of choice for Rust’s Cargo, many Python tools (pyproject.toml), and a growing set of infrastructure utilities. Its strength is an unambiguous, explicitly typed syntax. When you build or test a TOML parser or a config-driven feature, you need valid sample documents that exercise tables, arrays, and the various scalar types. This tool generates them.
How it works
The generator serializes a structured value into TOML. Top-level scalars are emitted first, then named tables appear under [section] headers, and repeated structures use the array-of-tables form [[section]], where each block becomes one array element.
Type rendering follows the TOML spec exactly: integers and floats are bare, booleans render as true/false, datetimes use the RFC 3339 form, arrays use square brackets, and strings are double-quoted with backslash and quote escaping. Because TOML does not infer string ambiguity the way YAML does, every string is quoted, which keeps the output unambiguous and parser-safe. A generic preset and a Cargo.toml-style preset shape the document.
Tips and notes
- Validate the output with a TOML parser (for example
tomlin Python ortoml::from_strin Rust); it should parse cleanly. - The Cargo preset is structurally faithful but not validated by cargo, so confirm it before dropping it into a real crate.
- Datetimes use RFC 3339, which is the only datetime form TOML accepts.
- Increase the array-of-tables count to test how a parser handles many repeated sections.