PHPackages                             lemukarram/toon - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. lemukarram/toon

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

lemukarram/toon
===============

A compact, token-efficient data format for AI prompts, developed by Tech With Muk.

01PHP

Since Nov 10Pushed 7mo agoCompare

[ Source](https://github.com/lemukarram/toon)[ Packagist](https://packagist.org/packages/lemukarram/toon)[ RSS](/packages/lemukarram-toon/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Toon
============

[](#laravel-toon)

[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![Author](https://camo.githubusercontent.com/99c6d429dadd303d3cd4cae9cd9fbaa8ecf301cf94b9d91a7a1308b1b33fb0de/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f417574686f722d54656368253230776974682532306d756b2d7265642e737667)](https://github.com/lemukarram)

A lightweight, token-efficient data format specifically designed for optimizing AI prompts in Laravel applications. Developed by **[Mukarram Hussain](https://github.com/lemukarram)** of **Tech with muk**.

When sending data to LLMs (like ChatGPT, Claude, or Gemini), standard JSON uses too many tokens due to repeated keys and braces. This package converts your PHP arrays into a highly compact, human-readable "Toon" notation, saving you money and context window space.

Features
--------

[](#features)

- 🚀 **`jsonToToon`**: Convert PHP Arrays or JSON to compact notation.
- 🔢 **`countTokens`**: Estimate the token usage of your strings.
- 📉 **Smart Compression**: Automatically converts lists of objects (like Eloquent collections) into a clean, CSV-style table format to save maximum tokens.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require lemukarram/toon
```

The package will automatically register its service provider and facade.

Usage
-----

[](#usage)

### 1. Compressing Data for AI Prompts

[](#1-compressing-data-for-ai-prompts)

Use the `Toon` facade to convert your data before sending it to an AI API.

```
use LeMukarram\Toon\Facades\Toon;

$data = [
    'user' => 'Mukarram',
    'skills' => ['Laravel', 'PHP', 'AI', 'CodeIgniter', 'Shopify'],
    'projects' => [
        ['name' => 'AI Influencer', 'status' => 'Active'],
        ['name' => 'Laravel Package', 'status' => 'Done'],
    ]
];

$promptContext = Toon::jsonToToon($data);

/*
 * The output ($promptContext) will be:
 *
 * user: Mukarram
 * skills:
 * 0: Laravel
 * 1: PHP
 * 2: AI
 * 3: CodeIgniter
 * 4: Shopify
 * projects:
 * @[2](name,status):
 * "AI Influencer",Active
 * "Laravel Package",Done
 */
```

### 2. Estimating Token Usage

[](#2-estimating-token-usage)

Check how many tokens you are saving.

```
$jsonTokens = Toon::countTokens(json_encode($data));
$toonTokens = Toon::countTokens($promptContext);

echo "JSON Tokens: $jsonTokens"; // e.g., ~70
echo "Toon Tokens: $toonTokens"; // e.g., ~45
```

Credits
-------

[](#credits)

- **[Mukarram Hussain](https://www.google.com/url?sa=E&source=gmail&q=https://github.com/lemukarram)** (Tech with muk)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://www.google.com/search?q=LICENSE) for more information.

```

```

###  Health Score

16

—

LowBetter than 4% of packages

Maintenance44

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c04560f6cb16b1a396120c0ae12dae19235afbd6c10b2af7b7dbb89671bf076a?d=identicon)[lemukarram](/maintainers/lemukarram)

---

Top Contributors

[![lemukarram](https://avatars.githubusercontent.com/u/96775183?v=4)](https://github.com/lemukarram "lemukarram (2 commits)")

### Embed Badge

![Health badge](/badges/lemukarram-toon/health.svg)

```
[![Health](https://phpackages.com/badges/lemukarram-toon/health.svg)](https://phpackages.com/packages/lemukarram-toon)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
