Download the PHP package helgesverre/toon without Composer

On this page you can find all versions of the php package helgesverre/toon. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package toon

TOON (Token-Oriented Object Notation)

Packagist Version Total Downloads License Try it

A PHP port of toon-format/toon - a compact data format designed to reduce token consumption when sending structured data to Large Language Models.

Contents

What is TOON?

TOON is a compact, human-readable format for structured data optimized for LLM contexts. For format details and efficiency analysis, see the TOON Specification.

Installation

Install via Composer:

Requirements

Quick Start

Try it online at ArrayAlchemy.

Basic Usage

Decoding TOON

TOON supports bidirectional conversion - you can decode TOON strings back to PHP arrays:

Note: TOON objects are decoded as PHP associative arrays, not objects.

Validating TOON

You can validate TOON input without decoding it to PHP values:

Tabular Format

TOON's most efficient format is for uniform object arrays:

Output:

Field names are declared once in the header, then each row contains only values. This is where TOON achieves the largest token savings compared to JSON.

See docs/EXAMPLES.md for more encoding examples.

Configuration Options

Customize encoding behavior with EncodeOptions:

Special Value Handling

String Quoting

TOON only quotes strings when necessary:

DateTime Objects

DateTime objects are automatically converted to ISO 8601 format:

PHP Enums

PHP enums are automatically normalized - BackedEnum values are extracted, UnitEnum names are used:

Special Numeric Values

Non-finite numbers are converted to null:

Helper Functions

TOON provides global helper functions for convenience:

Tutorials

Step-by-step guides for integrating TOON with LLM providers:

Getting Started

Framework Integrations

Advanced Topics

See the tutorials/ directory for all tutorials and learning paths.

Version Compatibility

This library tracks the TOON Specification. Major versions align with spec versions.

Library Spec Key Changes
v3.2.0 v3.3 \uXXXX control-character escapes, empty-array decoding ([], key: []), strict rejection of [03] and duplicate keys, number canonical range, quoted-key colon fix, validation API
v3.1.0 v3.0 toJSON() method support, negative leading zeros fix
v3.0.0 v3.0 List-item objects with tabular first field use depth +2 for rows
v2.0.0 v2.0 Removed [#N] length marker; decoder rejects legacy format
v1.4.0 v1.3 Full decoder, strict mode
v1.3.0 v1.3 PHP enum support
v1.2.0 v1.3 Empty array fix
v1.1.0 v1.3 Benchmarks, justfile
v1.0.0 v1.3 Initial release

For format details and token efficiency analysis, see the TOON Specification.

Format Rules

Objects

Arrays

Indentation

PHP-Specific Limitations

Numeric Key Handling

PHP automatically converts numeric string keys to integers in arrays:

The library handles this by quoting numeric keys when encoding.

Use Cases

TOON is ideal for:

Note: TOON is optimized for LLM contexts and is not intended as a replacement for JSON in APIs or data storage.

Differences from JSON

TOON is not a strict superset or subset of JSON. Key differences:

Credits

License

MIT License

Development

Testing

Specification Sync

Keep the library aligned with upstream spec changes:

The autofix command downloads the latest specification, then launches Claude Code in plan mode with the /spec-review prompt to analyze changes and propose implementation updates.

Benchmarks

See benchmarks/README.md for details.


All versions of toon with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package helgesverre/toon contains the following files

Loading the files please wait ...