{"id":33289512,"url":"https://github.com/caiocdcs/zig-toon","last_synced_at":"2026-06-20T14:03:22.404Z","repository":{"id":324775227,"uuid":"1098488130","full_name":"caiocdcs/zig-toon","owner":"caiocdcs","description":"Zig - Token-Oriented Object Notation – JSON for LLMs at half the token cost","archived":false,"fork":false,"pushed_at":"2025-11-17T19:07:37.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-17T21:08:24.966Z","etag":null,"topics":["ai","config","llm","toon","zig","zig-package"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/caiocdcs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-17T18:54:50.000Z","updated_at":"2025-11-17T19:07:41.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/caiocdcs/zig-toon","commit_stats":null,"previous_names":["caiocdcs/zig-toon"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/caiocdcs/zig-toon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caiocdcs%2Fzig-toon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caiocdcs%2Fzig-toon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caiocdcs%2Fzig-toon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caiocdcs%2Fzig-toon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caiocdcs","download_url":"https://codeload.github.com/caiocdcs/zig-toon/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caiocdcs%2Fzig-toon/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284964283,"owners_count":27091965,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-17T02:00:06.431Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","config","llm","toon","zig","zig-package"],"created_at":"2025-11-17T22:01:09.179Z","updated_at":"2025-11-17T22:03:31.907Z","avatar_url":"https://github.com/caiocdcs.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zig-toon\n\nSpec-compliant Zig implementation of [TOON v2.0](https://github.com/toon-format/spec) - a compact format for LLM data transfer.\n\nToken-Oriented Object Notation is a compact, human-readable format designed for passing structured data to Large Language Models with significantly reduced token usage.\n\nTOON excels at uniform complex objects – multiple fields per row, same structure across items. It borrows YAML's indentation-based structure for nested objects and CSV's tabular format for uniform data rows, then optimizes both for token efficiency in LLM contexts.\n\n## Quick Example\n\n**JSON** (40 bytes):\n```json\n{\"users\":[{\"id\":1,\"name\":\"Alice\"},{\"id\":2,\"name\":\"Bob\"}]}\n```\n\n**TOON** (28 bytes - 30% smaller):\n```\nusers[2]{id,name}:\n  1,Alice\n  2,Bob\n```\n\n## Installation\n\n```bash\ngit clone https://github.com/caiocdcs/zig-toon\ncd zig-toon\nzig build\n```\n\n## Usage\n\n```zig\nconst toon = @import(\"zig_toon\");\n\n// Encode\nconst encoded = try toon.encode(allocator, value, .{});\ndefer allocator.free(encoded);\n\n// Decode to generic Value\nvar value = try toon.decode(allocator, source, .{});\ndefer value.deinit(allocator);\n\n// Decode directly into Zig types\nconst User = struct { name: []const u8, age: i32 };\nconst user = try toon.decodeInto(User, allocator, \"name: Alice\\nage: 30\", .{});\ndefer allocator.free(user.name);\n```\n\n### Options\n\n```zig\n// Custom indent and delimiter\nconst encoded = try toon.encode(allocator, value, .{\n    .indent = 4,\n    .delimiter = .tab,\n});\n\n// Strict validation (default: true)\nvar decoded = try toon.decode(allocator, source, .{\n    .strict = false,\n});\n```\n\n## Testing\n\n```bash\nzig build test  # 212 tests, all passing\n```\n\n## Features\n\n- Full TOON v2.0 spec compliance\n- Primitives, objects, arrays (primitive, tabular, nested, mixed)\n- Direct deserialization into Zig types with `decodeInto`\n- Optional fields, default values, enums, nested structs\n- Custom delimiters (comma, tab, pipe)\n- Strict validation mode\n- Zero memory leaks\n\n### decodeInto\n\nDeserialize TOON directly into Zig types:\n\n```zig\n// Structs\nconst User = struct { name: []const u8, age: i32 };\nconst user = try toon.decodeInto(User, allocator, input, .{});\n\n// Arrays\nconst nums = try toon.decodeInto([]i32, allocator, \"[3]: 10,20,30\", .{});\n\n// With optionals and defaults\nconst Config = struct {\n    host: []const u8 = \"localhost\",\n    port: ?i32,\n};\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaiocdcs%2Fzig-toon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaiocdcs%2Fzig-toon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaiocdcs%2Fzig-toon/lists"}