A formatter for your kdl files
2 comments
·May 9, 2025netbioserror
KDL seems like such a fantastic format. It's well-defined, and a parser can easily be built from the spec. It's explicitly and exclusively textual. It's an excellent rethink of node-based syntax and works fantastically for XML and HTML. Staggeringly, in my own testing, it can represent JSON maps and lists, as well as tabular formats, and even mix them, while still being slim, clear, unambiguously parsable, and human-readable. It's like a best of all worlds for a textual format. As with any node-based format, a parser hook to convert to and from pre-built types is probably necessary in most scenarios, but that's a small price to pay.
It really needs some strong word-of-mouth.
For anyone curious, you can represent tabular data using sentinel - child nodes for rows:
WeatherTable City Temperature Conditions {
- Chicago 14 blizzard
- "New York" 33 rain
- Miami 68 sunny
- "Los Angeles" 55 sunny
}
Just wanted to give a quick shoutout to a project I stumbled across recently: [kdlfmt](https://github.com/hougesen/kdlfmt). It’s a command-line formatter for [KDL](https://kdl.dev) files, written in Rust. I’m not the author or maintainer, just a happy user who thinks it deserves a bit more attention.
For neovim users I also added the formatter to the registry so once it's merged you should be able to use it for your kdl files. would be great if you could give the formatter a star as I think the mason registry needs a minimum of 100 stars to be accepted.