Not Another Markup Language
Oct 6, 2025
I defined a subset of YAML that only requires a JSON parser (and a tiny conversion func).
If you ever thought, I want something like a simple YAML parser but man those YAML parsers are monstrous, read on.
The format is basically HTTP headers where all values are JSON:
template: "home"
page_classes: ["page--jumbo"]
cta: {
"primary": {
"title": "Click me",
"href": "http://example.com/"
}
}
Syntax:
- Each non-empty line is a
key: value
pair. - Each value is a valid JSON.
- You can continue a value on multiple lines by indenting all continuation lines (using spaces or tabs).
#
starts a comment if it’s the first non-whitespace character on the line.
That’s it.
This is valid YAML, and is trivial to convert into an actual JSON, so you can use all features of your stdlib JSON parser.
I wrote a simple converter for Go as andreyvit/naml that you should just copy into your project.
For bonus points, combine it with andreyvit/jsonfix to allow trailing commas in that inline JSON.