{"id":46133824,"url":"https://github.com/sbsaga/toon","last_synced_at":"2026-03-02T04:31:10.870Z","repository":{"id":322041592,"uuid":"1088024590","full_name":"sbsaga/toon","owner":"sbsaga","description":"TOON — Laravel AI package for compact, human-readable, token-efficient data format with JSON ⇄ TOON conversion for ChatGPT, OpenAI, and other LLM prompts.","archived":false,"fork":false,"pushed_at":"2025-12-20T18:06:42.000Z","size":2460,"stargazers_count":39,"open_issues_count":0,"forks_count":7,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-22T16:06:43.558Z","etag":null,"topics":["ai","ai-library","api-optimization","chatgpt","compact-format","data-compression","developer-tool","human-readable","json","laravel","laravel-package","large-language-models","llm","openai","php","php-library","prompt-engineering","serialization","token-optimization","toon"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/sbsaga/toon","language":"PHP","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/sbsaga.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-02T06:18:26.000Z","updated_at":"2025-12-20T18:05:45.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/sbsaga/toon","commit_stats":null,"previous_names":["sbsaga/toon"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/sbsaga/toon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbsaga%2Ftoon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbsaga%2Ftoon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbsaga%2Ftoon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbsaga%2Ftoon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sbsaga","download_url":"https://codeload.github.com/sbsaga/toon/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbsaga%2Ftoon/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29992302,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T01:47:34.672Z","status":"online","status_checked_at":"2026-03-02T02:00:07.342Z","response_time":60,"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","ai-library","api-optimization","chatgpt","compact-format","data-compression","developer-tool","human-readable","json","laravel","laravel-package","large-language-models","llm","openai","php","php-library","prompt-engineering","serialization","token-optimization","toon"],"created_at":"2026-03-02T04:31:10.164Z","updated_at":"2026-03-02T04:31:10.836Z","avatar_url":"https://github.com/sbsaga.png","language":"PHP","readme":"# 🧠 TOON for Laravel  \n### Compact · Token-Efficient · Human-Readable Data Format for AI Prompts \u0026 LLM Contexts  \n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/sbsaga/toon/main/assets/logo.webp\" alt=\"TOON Logo\" width=\"180\"\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://packagist.org/packages/sbsaga/toon\"\u003e\n    \u003cimg src=\"https://img.shields.io/packagist/v/sbsaga/toon\" alt=\"Latest Version\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://packagist.org/packages/sbsaga/toon\"\u003e\n    \u003cimg src=\"https://img.shields.io/packagist/dt/sbsaga/toon\" alt=\"Total Downloads\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/sbsaga/toon\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/stars/sbsaga/toon\" alt=\"GitHub stars\"\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/github/license/sbsaga/toon\" alt=\"License\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Laravel-9%2B-orange\" alt=\"Laravel 9+\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/PHP-8.1%2B-blue\" alt=\"PHP 8.1+\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/AI-Ready-success\" alt=\"AI Ready\"\u003e\n\u003c/p\u003e\n\n---\n\n## 📚 Table of Contents  \n1. [Overview](#-overview)  \n2. [Key Features](#-key-features)  \n3. [Benchmark \u0026 Analytics](#-real-world-benchmark)  \n4. [Installation](#-installation)  \n5. [Configuration](#-configuration)  \n6. [Usage](#-usage)  \n7. [Quick Benchmark Route](#-quick-benchmark-route)  \n8. [Analytics \u0026 Visualization](#-analytics--visualization)  \n9. [CLI Commands](#-artisan-commands)  \n10. [Integration Use Cases](#-integration-use-cases)  \n11. [Compatibility](#-compatibility)  \n12. [Compression Visualization](#-example-compression-visualization)  \n13. [SEO \u0026 AI Integration Keywords](#-seo--ai-integration-keywords)  \n14. [License](#-license)  \n\n---\n\n## ✨ Overview  \n\n**TOON for Laravel** — also known as **Token-Optimized Object Notation** — is a **Laravel-native AI data optimization library** that transforms large JSON or PHP arrays into a **compact, readable, and token-efficient format**.  \n\nIt’s crafted for developers working with **ChatGPT, Gemini, Claude, Mistral, or OpenAI APIs**, helping you:  \n✅ Save tokens and reduce API costs  \n✅ Simplify complex prompt structures  \n✅ Improve AI response quality and context understanding  \n✅ Maintain human readability and reversibility  \n\n\u003e 💬 *“Compress your prompts, not your ideas.”*  \n\n---\n\n## 🚀 Key Features  \n\n| Feature | Description |\n|----------|-------------|\n| 🔁 **Bidirectional Conversion** | Convert JSON ⇄ TOON with ease |\n| 🧩 **Readable \u0026 Compact** | YAML-like structure, human-friendly format |\n| 💰 **Token-Efficient** | Save up to 70% tokens on every AI prompt |\n| ⚙️ **Seamless Laravel Integration** | Built with Facades, Service Providers, and Artisan commands |\n| 🔒 **Preserves Key Order** | Ensures deterministic data output |\n| 📊 **Built-in Analytics** | Measure token, byte, and compression performance |\n| 🌍 **AI \u0026 LLM Ready** | Optimized for ChatGPT, Gemini, Claude, and Mistral models |\n| 🆕 **Complex Nested Array Support** | Fully supports deeply nested associative and indexed arrays |\n\n---\n\n## 🆕 Complex \u0026 Nested Array Support (v1.1.8+)\n\nTOON now supports **deeply nested and mixed data structures**, including:\n\n- Multi-level associative arrays  \n- Indexed collections inside objects  \n- Complex real-world structures like users, profiles, orders, metadata, and logs  \n\nThis enhancement ensures that **no structural information is lost**, while still benefiting from TOON’s compact, token-efficient format.\n\n### Example: Nested Data Conversion\n\n```php\n$data = [\n    'user' =\u003e [\n        'id' =\u003e 101,\n        'active' =\u003e true,\n        'roles' =\u003e ['admin', 'editor'],\n        'profile' =\u003e [\n            'age' =\u003e 32,\n            'location' =\u003e [\n                'city' =\u003e 'Delhi',\n                'country' =\u003e 'India',\n            ],\n        ],\n    ],\n    'orders' =\u003e [\n        [\n            'order_id' =\u003e 'ORD-1001',\n            'amount' =\u003e 1998,\n            'status' =\u003e 'paid',\n        ],\n    ],\n];\n\necho Toon::convert($data);\n```\n\nThis structure remains **human-readable, reversible, and compact**, even with deep nesting.\n\n---\n\n## 🧪 Real-World Benchmark  \n\n| Metric | JSON | TOON | Reduction |\n|---------|------|------|-----------|\n| Size (bytes) | 7,718 | 2,538 | **67.12% smaller** |\n| Tokens (est.) | 1,930 | 640 | **~66.8% fewer tokens** |\n\n### 📈 Visual Comparison  \n\n```\nJSON (7.7 KB)\n██████████████████████████████████████████████████████████████████████████\n\nTOON (2.5 KB)\n█████████████████\n```\n\n💡 **TOON** reduces token load by *60–75%*, improving **AI efficiency**, **cost**, and **response quality**.\n\n---\n\n## ⚙️ Installation  \n\n```bash\ncomposer require sbsaga/toon\n```\n\n\u003e Laravel automatically discovers the Service Provider and Facade.  \n\n---\n\n## ⚙️ Configuration  \n\n```bash\nphp artisan vendor:publish --provider=\"Sbsaga\\Toon\\ToonServiceProvider\" --tag=config\n```\n\nCreates a configuration file at `config/toon.php`:\n\n```php\nreturn [\n    'enabled' =\u003e true,\n    'escape_style' =\u003e 'backslash',\n    'min_rows_to_tabular' =\u003e 2,\n    'max_preview_items' =\u003e 200,\n];\n```\n\n---\n\n## 🧠 Usage  \n\n### ➤ Convert JSON → TOON  \n\n```php\nuse Sbsaga\\Toon\\Facades\\Toon;\n\n$data = [\n    'user' =\u003e 'Sagar',\n    'message' =\u003e 'Hello, how are you?',\n    'tasks' =\u003e [\n        ['id' =\u003e 1, 'done' =\u003e false],\n        ['id' =\u003e 2, 'done' =\u003e true],\n    ],\n];\n\n$converted = Toon::convert($data);\necho $converted;\n```\n\n**Output:**\n\n```\nuser: Sagar\nmessage: Hello\\, how are you?\ntasks:\n  items[2]{done,id}:\n    false,1\n    true,2\n```\n\n---\n\n### ➤ Convert TOON → JSON  \n\n```php\n$toon = \u003c\u003c\u003cTOON\nuser: Sagar\ntasks:\n  items[2]{id,done}:\n    1,false\n    2,true\nTOON;\n\n$json = Toon::decode($toon);\nprint_r($json);\n```\n\n---\n\n### ➤ Estimate Tokens  \n\n```php\n$stats = Toon::estimateTokens($converted);\nprint_r($stats);\n```\n\n**Output:**\n\n```json\n{\n  \"words\": 20,\n  \"chars\": 182,\n  \"tokens_estimate\": 19\n}\n```\n\n---\n\n## 🧪 Quick Benchmark Route  \n\n```php\nuse Illuminate\\Support\\Facades\\Route;\nuse Sbsaga\\Toon\\Facades\\Toon;\n\nRoute::get('/toon-benchmark', function () {\n    $json = json_decode(file_get_contents(storage_path('app/users.json')), true);\n    $jsonEncoded = json_encode($json, JSON_PRETTY_PRINT);\n    $toonEncoded = Toon::convert($json);\n\n    return response()-\u003ejson([\n        'json_size_bytes' =\u003e strlen($jsonEncoded),\n        'toon_size_bytes' =\u003e strlen($toonEncoded),\n        'saving_percent' =\u003e round(100 - (strlen($toonEncoded) / strlen($jsonEncoded) * 100), 2),\n        'json_content' =\u003e $jsonEncoded,\n        'toon_content' =\u003e $toonEncoded,\n    ]);\n});\n```\n\n---\n\n## 📊 Analytics \u0026 Visualization  \n\n| Metric | Description | Example |\n|--------|--------------|---------|\n| `json_size_bytes` | Original JSON size | 7,718 |\n| `toon_size_bytes` | Optimized TOON size | 2,538 |\n| `saving_percent` | Space saved | 67.12% |\n| `tokens_estimate` | Estimated token count | 640 |\n| `compression_ratio` | Ratio (TOON/JSON) | 0.33 |\n\n🧠 **Visual Graph (Efficiency Comparison)**  \n\n```\n| JSON: ██████████████████████████████████████████████████████████ 100%\n| TOON: ████████████ 33%\n```\n\n---\n\n## 🧰 Artisan Commands  \n\n```bash\nphp artisan toon:convert storage/test.json\nphp artisan toon:convert storage/test.toon --decode --pretty\nphp artisan toon:convert storage/test.json --output=storage/result.toon\n```\n\n---\n\n## 🧩 Integration Use Cases  \n\n| Use Case | Benefit |\n|-----------|----------|\n| 🤖 **AI Prompt Engineering** | Compress structured data for ChatGPT / LLMs |\n| 📉 **Token Optimization** | Reduce token usage and API costs |\n| 🧠 **Data Preprocessing** | Streamline complex structured inputs |\n| 🧾 **Logging \u0026 Debugging** | Store compact, readable structured logs |\n| 🗄️ **Database Storage Optimization** | Reduce JSON storage size while preserving structure |\n| 🔍 **Developer Tools** | Perfect for previews and compact dashboards |\n\n---\n\n## 🧰 Compatibility  \n\n| Laravel | PHP | Package Version |\n|----------|-----|----------------|\n| 9.x – 12.x | ≥ 8.1 | v1.1.0+ |\n\n---\n\n## 📉 Example Compression Visualization  \n\n```\nJSON (7.7 KB)\n██████████████████████████████████████████████████████████████████████████\n\nTOON (2.5 KB)\n█████████████████\n```\n\n🧠 **~67% size reduction** while retaining complete data accuracy.\n\n---\n\n## 🌐 SEO \u0026 AI Integration Keywords  \n\n**Keywords:**  \n`laravel ai`, `ai for laravel`, `chatgpt laravel`, `laravel chatgpt`, `gemini laravel`, `laravel gemini`, `laravel anthropic`, `laravel mistral`, `laravel openai`, `openai laravel`, `laravel llm`, `llm laravel`, `ai laravel package`, `prompt compression`, `token optimizer`, `laravel json formatter`, `compact notation`, `laravel data compressor`, `token saver`, `laravel ai integration`, `sbsaga toon`, `laravel-toon`, `toon php`, `laravel ai toolkit`, `openai cost optimizer`, `laravel ai efficiency`, `chatgpt laravel toolkit`, `ai-ready laravel package`.\n\n---\n\n## 💡 Contribution  \n\nContributions are highly encouraged!  \n- Fork the repository  \n- Create a new feature branch  \n- Commit \u0026 push improvements  \n- Submit a Pull Request 🎉  \n\n---\n\n## 📜 License  \n\nLicensed under the **MIT License** — free for both commercial and personal use.\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cb\u003e🧠 “Compress your prompts, not your ideas.” — TOON helps you talk to AI efficiently.\u003c/b\u003e\n\u003c/p\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbsaga%2Ftoon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbsaga%2Ftoon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbsaga%2Ftoon/lists"}