Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Toon Laravel Package

knackline/laravel-toon

View on GitHub
Deep Wiki
Context7

Laravel Toon

A powerful Laravel package for converting between JSON and Toon format. Seamlessly transform your JSON data into a compact, human-readable Toon format and back again.

Installation

You can install the package via Composer:

composer require knackline/laravel-toon

The package will automatically register its service provider and facade.

Usage

Converting JSON to Toon Format

use Knackline\LaravelToon\Toon;

$jsonData = [
    "context" => [
        "task" => "Our favorite hikes together",
        "location" => "Boulder",
        "season" => "spring_2025"
    ],
    "friends" => ["ana", "luis", "sam"],
    "hikes" => [
        [
            "id" => 1,
            "name" => "Blue Lake Trail",
            "distanceKm" => 7.5,
            "elevationGain" => 320,
            "companion" => "ana",
            "wasSunny" => true
        ]
    ]
];

$toon = Toon::fromJson($jsonData);

Output:

context:
  task: Our favorite hikes together
  location: Boulder
  season: spring_2025
friends[3]: ana,luis,sam
hikes[3]{id,name,distanceKm,elevationGain,companion,wasSunny}:
  1,Blue Lake Trail,7.5,320,ana,true
  2,Ridge Overlook,9.2,540,luis,false
  3,Wildflower Loop,5.1,180,sam,true

Converting Toon Format to JSON

$toonString = "context:
  task: Our favorite hikes together
  location: Boulder
  season: spring_2025
friends[3]: ana,luis,sam
hikes[3]{id,name,distanceKm,elevationGain,companion,wasSunny}:
  1,Blue Lake Trail,7.5,320,ana,true
  2,Ridge Overlook,9.2,540,luis,false";

$jsonData = Toon::toJson($toonString);

Using the Facade

If you prefer using facades:

use Knackline\LaravelToon\Facades\Toon;

$toon = Toon::fromJson($data);
$json = Toon::toJson($toon);

Format Specification

Simple Values

key: value

Objects (Associative Arrays)

key:
  nestedKey: value
  anotherKey: value

Simple Arrays

key[count]: value1,value2,value3

Arrays of Objects

key[count]{field1,field2,field3}:
  value1,value2,value3
  value4,value5,value6

Supported Data Types

  • Strings: Plain text values
  • Numbers: Integers and floats (e.g., 7.5, 320)
  • Booleans: true and false
  • Null: Empty values
  • Arrays: Both indexed and associative arrays
  • Nested Objects: Multi-level object structures

Requirements

  • PHP 8.1 or higher
  • Laravel 9.0, 10.0, or 11.0

License

The MIT License (MIT). Please see the License File for more information.

Support

For issues, questions, or contributions, please visit the GitHub repository.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui