r/C_Programming • u/mattewong • Jul 01 '26
Project Open Source C libraries for TOON format generation, parsing, and conversion (toonwriter, yatl, json2toon)
Hello r/C_programming,
I have recently open-sourced three related C constant-memory-bound libraries for reading, writing and converting TOON (Token-Oriented Object Notation) data serialization format.
NOTE ON THE USE OF AI: This code was written by me with the assistance of Claude Code, used to accelerate, not to replace, the coding process that I have been practicing for decades. Each library went through dozens of iterations to ensure formal spec compliance and quality code and QA out of the gates. THIS IS NOT AI SLOP.
TOON is a line-oriented, indentation-based text format that is a lossless alternative to JSON. It is primarily designed to optimize structured data exchange with Large Language Models (LLMs) by minimizing token overhead. It achieves a typical 20–60% reduction in token count compared to standard JSON by using YAML-style whitespace indentation for nested objects and single-header, CSV-style layouts for arrays of uniform structures.
Library Overview
- toonwriter: A low-overhead C library for streaming output (to file or custom stream) in TOON format
- yatl: Memory-bound sax/streaming parsing library for TOON input from file or custom stream. The API mimics that of the YAJL json parser.
- json2toon: Utility and library for streaming, two-way JSON <=> TOON conversion
The repositories are designed with standard C conventions, minimal external runtime dependencies, and portability in mind.
If you are working on LLM data pipelines, text processing, or lightweight data serialization tools, feel free to look through the source code and give them a try.
Feedback is welcome. If you find the code helpful, please give it a star.
Repository Links:
•
u/AutoModerator Jul 01 '26
Hi /u/mattewong,
Your submission in r/C_Programming was filtered because it links to a git project.
You must edit the submission or respond to this comment with an explanation about how AI was involved in the creation of your project.
While AI-generated code is not disallowed, low-effort "slop" projects may be removed and it's likely that other users push back strongly on substantially AI-generated projects.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/skeeto Jul 03 '26
Nicely done! I see fuzz tests and a suitable allocator interface (one nit: realloc and free ought to accept the old object size). I shook it pretty hard and couldn't find any memory bugs whatsoever, which is unusual for a parser of this complexity.
I did manage to uncover some subtle parsing bugs against the spec (a good job to take Fable for a spin):
https://github.com/skeeto/yatl/commits/main/?author=skeeto
[]where it's disallowed by the spec.The parser has no concept of
indentSizefrom the spec, so it accepts inputs it should reject in strict mode, but it's not a straightforward fix. See this note.3
u/Beautiful_Stage5720 Jul 02 '26
It's so depressing that we can't even share projects anymore without immediately being written off as slop. This does not look like slop to me, OP.
3
u/Sqydev Jul 02 '26
Well, I don’t do ai stuff but it sounds cool.
1
u/Deep_Ad1959 Jul 03 '26
the number that always bites a fresh repo like this isn't stars, it's that changelog readership drops toward zero within a couple weeks even as commits keep landing (the skeeto spec fixes will prove it, those'll be your busiest week). release-note posts don't close that gap because nobody re-opens them. the only thing people actually track past launch is the commit stream itself. written with ai