toon.hpp is a lightweight cpp header for reading, writing, and editing TOON (Token-Oriented Object Notation) files.
TOON is a structured configuration format designed to be compact, readable, and efficient. toon.hpp allows C++ programs to parse .toon files into dynamic objects, modify them, and write them back to disk.
- Header-only library
- Parse TOON text and files
- Write and overwrite
.toonfiles - Dynamic value system (objects, arrays, strings, numbers, booleans)
- Nested object editing
- Minimal dependencies (C++ standard library only)
Clone the repository:
git clone https://github.com/xZepyx/toon.hppAdd the header to your project:
#include "toon/toon.hpp"
No linking or build configuration is required.
#include "toon/toon.hpp"
#include <iostream>
int main() {
toon::value config;
config["window"]["width"] = 1280;
config["window"]["height"] = 720;
config["user"]["name"] = "zepyx";
config["user"]["admin"] = true;
std::cout << toon::dump(config);
toon::write_file("config.toon", config);
}Output:
window:
width: 1280
height: 720
user:
name: zepyx
admin: true
auto config = toon::parse_file("config.toon");
int width = config["window"]["width"];Example config.toon:
window:
width: 1280
height: 720
toon::write_file("config.toon", config);This serializes the structure and overwrites the file.
auto cfg = toon::parse_file("config.toon");
cfg["window"]["width"] = 1920;
cfg["window"]["height"] = 1080;
toon::write_file("config.toon", cfg);toon::value fruits;
fruits.push_back("apple");
fruits.push_back("banana");
fruits.push_back("orange");Serialized output:
- apple
- banana
- orange
auto data = toon::parse(R"(
user:
name: Alice
admin: true
)");Documentation: docs/root.md
Todo: docs/todo.md
© 2025 xZepyx — Licensed under the MIT License.
Early development version.
APIs may change as the parser and format support expand.
Feel free to contribute. It's a open-source project duh?