PHPackages                             knackline/excel-to-x - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. knackline/excel-to-x

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

knackline/excel-to-x
====================

Laravel Package that converts excel to JSON/collection

2.1.2(5mo ago)448.1k↓24.2%2[1 PRs](https://github.com/Knackline/laravel-excel-to-x/pulls)MITPHPPHP ^8.2

Since Apr 14Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/Knackline/laravel-excel-to-x)[ Packagist](https://packagist.org/packages/knackline/excel-to-x)[ RSS](/packages/knackline-excel-to-x/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (5)Versions (9)Used By (0)

Laravel Excel to JSON / Collection / Array / Toon
=================================================

[](#laravel-excel-to-json--collection--array--toon)

This Laravel package provides utilities for converting Excel files to JSON format, Laravel Collections, PHP Arrays, or Toon format. It also supports reading data from multiple sheets within an Excel file.

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

[](#installation)

You can install the package via Composer:

```
composer require knackline/excel-to-x
```

Usage
-----

[](#usage)

### JSON Conversion

[](#json-conversion)

To convert an Excel file to JSON format, use the `json` method of the `ExcelTo` class:

```
use Knackline\ExcelTo\ExcelTo;

$jsonData = ExcelTo::json('path/to/your/excel_file.xlsx');
```

This will return a JSON-encoded string representing the Excel data. If the Excel file contains multiple sheets, the data will be organized by sheet names.

### Collection Conversion

[](#collection-conversion)

To convert an Excel file to a Laravel Collection, use the `collection` method of the `ExcelTo` class:

```
use Knackline\ExcelTo\ExcelTo;

$collection = ExcelTo::collection('path/to/your/excel_file.xlsx');
```

This will return a Laravel Collection containing the Excel data. When multiple sheets are present, each sheet's data will be a collection keyed by the sheet name.

### Array Conversion

[](#array-conversion)

To convert an Excel file to a PHP Array, use the `array` method of the `ExcelTo` class:

```
use Knackline\ExcelTo\ExcelTo;

$arrayData = ExcelTo::array('path/to/your/excel_file.xlsx');
```

This will return a PHP array containing the Excel data. Similar to JSON and Collection, multiple sheets will be keyed by their names.

### Toon Conversion

[](#toon-conversion)

To convert an Excel file to Toon format (a compact, AI-Optimized format), use the `toon` method of the `ExcelTo` class:

```
use Knackline\ExcelTo\ExcelTo;

$toonData = ExcelTo::toon('path/to/your/excel_file.xlsx');
```

This will return a Toon format string representing the Excel data. The Toon format is a compact, AI-Optimized format that efficiently represents structured data. When multiple sheets are present, each sheet's data will be organized in the Toon format.

Example
-------

[](#example)

```
use Knackline\ExcelTo\ExcelTo;

// Convert Excel to JSON
$jsonData = ExcelTo::json('path/to/your/excel_file.xlsx');

// Convert Excel to Collection
$collection = ExcelTo::collection('path/to/your/excel_file.xlsx');

// Convert Excel to Array
$arrayData = ExcelTo::array('path/to/your/excel_file.xlsx');

// Convert Excel to Toon
$toonData = ExcelTo::toon('path/to/your/excel_file.xlsx');
```

Requirements
------------

[](#requirements)

- PHP &gt;= 8.2
- Laravel &gt;= 8.x
- PhpSpreadsheet &gt;= 1.20
- knackline/laravel-toon &gt;= 1.0

Author
------

[](#author)

- **RAJKUMAR SAMRA** -  ([Github](https://github.com/rjsamra))

Contributing
------------

[](#contributing)

Contributions are welcome! Feel free to submit pull requests or open an issue if you find any bugs or have any suggestions for improvements.

License
-------

[](#license)

This package is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).

### Key Updates:

[](#key-updates)

1. **Support for Multiple Sheets:**

    - Described how the package handles multiple sheets, with data organized by sheet names.
2. **Array Conversion:**

    - Added a new section for array conversion, including an example of how to use the new `array` method.
3. **Clarified Output Format:**

    - Explained the structure of the data returned by each method, emphasizing the handling of single vs. multiple sheets.

Feel free to modify any section further if you have additional details or preferences for the README content.

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance72

Regular maintenance activity

Popularity36

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.8% 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.

###  Release Activity

Cadence

Every ~121 days

Recently: every ~136 days

Total

6

Last Release

156d ago

Major Versions

1.2.0 → 2.0.02024-08-07

### Community

Maintainers

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

---

Top Contributors

[![rjsamra](https://avatars.githubusercontent.com/u/31566509?v=4)](https://github.com/rjsamra "rjsamra (23 commits)")[![rj-origin](https://avatars.githubusercontent.com/u/165553811?v=4)](https://github.com/rj-origin "rj-origin (1 commits)")

---

Tags

excelexcel-conexcel-manipulationjsonknacklinelaravel

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/knackline-excel-to-x/health.svg)

```
[![Health](https://phpackages.com/badges/knackline-excel-to-x/health.svg)](https://phpackages.com/packages/knackline-excel-to-x)
```

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M712](/packages/maatwebsite-excel)[barryvdh/laravel-dompdf

A DOMPDF Wrapper for Laravel

7.3k87.6M278](/packages/barryvdh-laravel-dompdf)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

2.8k24.8M48](/packages/barryvdh-laravel-snappy)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[bfinlay/laravel-excel-seeder

Seed the database with Laravel using Excel, XLSX, XLS, CSV, ODS, Gnumeric, XML, HTML, SLK files

3944.4k](/packages/bfinlay-laravel-excel-seeder)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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