Weave 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

Toon Laravel Package

sbsaga/toon

View on GitHub
Deep Wiki
Context7

TOON Reference

Public API

Facade and service methods:

  • Toon::convert(mixed $input): string
  • Toon::convertWith(mixed $input, ?callable $replacer = null): string
  • Toon::encode(mixed $input): string
  • Toon::encodeWith(mixed $input, ?callable $replacer = null): string
  • Toon::decode(string $toon): array
  • Toon::encodeLines(mixed $input): \Generator
  • Toon::decodeFromLines(iterable $lines): array
  • Toon::skip(): object
  • Toon::estimateTokens(string $toon): array
  • Toon::diff(mixed $input): array
  • Toon::promptBlock(mixed $input, string $fenceLabel = 'toon'): string
  • Toon::validate(string $toon, bool $strict = true): array
  • Toon::contentType(): string
  • Toon::fileExtension(): string

Replacer callback contract:

  • signature: fn(array $path, string|int|null $key, mixed $value): mixed
  • return Toon::skip() to remove fields/items
  • called recursively on nested values

Global helpers:

  • toon_encode(mixed $data): string
  • toon_encode_with(mixed $data, callable $replacer): string
  • toon_encode_lines(mixed $data): array
  • toon_decode(string $toon): array
  • toon_diff(mixed $data): array
  • toon_prompt(mixed $data, string $label = 'toon'): string
  • toon_validate(string $toon, bool $strict = true): array

Collection macro:

  • collect($rows)->toToon(): string

Opt-in trait:

  • Sbsaga\Toon\Concerns\Toonable

Config Keys

  • enabled
  • escape_style
  • delimiter
  • min_rows_to_tabular
  • max_preview_items
  • coerce_scalar_types
  • strict_mode
  • compatibility_mode

Recommended Modes

  • use legacy when protecting existing serialized output contracts
  • use modern for new projects that want cleaner nested-data round trips

Related Guides

Suggested GitHub Topics

Apply these manually in the repository metadata for discoverability:

  • laravel
  • laravel-package
  • laravel-ai
  • toon
  • laravel-toon
  • llm
  • prompt-compression
  • token-optimization
  • structured-data
  • openai
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.
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels
wazza/laravel-db-encryption
hokny/laravel-generator
vonsogt/backup
jengo/queues
jeremykenedy/laravel-observability
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums