PHPackages                             noki/large-csv-converter - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. noki/large-csv-converter

ActiveLibrary[File &amp; Storage](/categories/file-storage)

noki/large-csv-converter
========================

Fast and memory-efficient Laravel package for converting large CSV, XLSX and JSON files.

v1.0.0(4mo ago)01MITPHPPHP ^8.1CI passing

Since Jan 1Pushed 4mo agoCompare

[ Source](https://github.com/novakurosevic/large-csv-converter)[ Packagist](https://packagist.org/packages/noki/large-csv-converter)[ RSS](/packages/noki-large-csv-converter/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Large CSV Converter
===================

[](#large-csv-converter)

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](LICENSE.md)**Laravel package for fast and memory-efficient CSV and Excel conversions.**

This package allows you to easily convert large CSV files to XLSX or JSON format, and vice versa — all while keeping low memory usage thanks to the excellent [OpenSpout](https://github.com/openspout/openspout) library.

---

🚀 Features
----------

[](#-features)

- Convert **CSV → XLSX**, **XLSX → CSV**, and **CSV → JSON**
- Stream-based processing for **very large files**
- **Memory-safe** even for multi-gigabyte CSVs
- Detects and handles **headers automatically**
- Fully compatible with **Laravel** (auto-discovery supported)
- Works on **Linux**, **macOS**, and **Windows**

---

🧩 Requirements
--------------

[](#-requirements)

- PHP ≥ 8.1
- Laravel ≥ 9.x
- PHP extensions:

    - `ext-zip`
    - `ext-xmlreader`

---

⚙️ Installation
---------------

[](#️-installation)

Install the package via Composer:

```
composer require noki/large-csv-converter
```

Laravel will automatically register the service provider and alias.

---

🧠 Basic Usage
-------------

[](#-basic-usage)

Import the class:

```
use Noki\LargeCsvConverter\LargeCsvConverter;
```

### 🟢 Example 1: Convert CSV → XLSX (simple)

[](#-example-1-convert-csv--xlsx-simple)

```
use Noki\LargeCsvConverter\LargeCsvConverter;

LargeCsvConverter::csvToXlsx(
    csv_file_path: '/var/www/html/large-csv/test.csv',
    excel_file_path: '/var/www/html/large-csv/test.xlsx',
);
```

This reads `test.csv` and creates `test.xlsx` in the specified directory. If the first row of the CSV is a header, it will be preserved automatically.

---

🧩 Advanced Usage (with optional parameters)
-------------------------------------------

[](#-advanced-usage-with-optional-parameters)

You can customize delimiters, encoding, and whether the first line is a header:

```
use Noki\LargeCsvConverter\LargeCsvConverter;

LargeCsvConverter::csvToXlsx(
    csv_file_path: '/var/www/html/large-csv/test.csv',
    excel_file_path: '/var/www/html/large-csv/test.xlsx',
    first_line_is_header: true,       // Default: true
    delimiter: ';',                   // Default: ','
    enclosure: '"',                   // Default: '"'
    encoding: 'UTF-8',                // Default: 'UTF-8'
);
```

---

🔄 XLSX → CSV
------------

[](#-xlsx--csv)

Convert Excel files back to CSV:

```
use Noki\LargeCsvConverter\LargeCsvConverter;

LargeCsvConverter::xlsxToCsv(
    csv_file_path: '/var/www/html/large-csv/output.csv',
    excel_file_path: '/var/www/html/large-csv/input.xlsx',
);
```

You can again customize options:

```
use Noki\LargeCsvConverter\LargeCsvConverter;

LargeCsvConverter::xlsxToCsv(
    csv_file_path: '/var/www/html/large-csv/output.csv',
    excel_file_path: '/var/www/html/large-csv/input.xlsx',
    first_line_is_header: true,   // Default: true
    delimiter: ',',               // Default: ','
    enclosure: '"'                // Default: '"'
);
```

---

📄 CSV → JSON
------------

[](#-csv--json)

Convert large CSVs directly into JSON files:

```
use Noki\LargeCsvConverter\LargeCsvConverter;

LargeCsvConverter::csvToJson(
    csv_file_path: '/var/www/html/large-csv/test.csv',
    json_file_path: '/var/www/html/large-csv/test.json',
);
```

Advanced example:

```
use Noki\LargeCsvConverter\LargeCsvConverter;

LargeCsvConverter::csvToJson(
    csv_file_path: '/var/www/html/large-csv/test.csv',
    json_file_path: '/var/www/html/large-csv/test.json',
    first_line_is_header: true,     // If CSV has header row
    delimiter: ',',                 // Field separator
    enclosure: '"',                 // Text enclosure
    encoding: 'UTF-8'               // File encoding
);
```

---

🧰 CSV → Array
-------------

[](#-csv--array)

Read CSV into PHP array (with header detection and memory checks):

```
use Noki\LargeCsvConverter\LargeCsvConverter;

$array = LargeCsvConverter::csvToArray(
    csv_file_path: '/var/www/html/large-csv/test.csv'
);
```

Advanced usage:

```
use Noki\LargeCsvConverter\LargeCsvConverter;

$array = LargeCsvConverter::csvToArray(
    csv_file_path: '/var/www/html/large-csv/test.csv',
    first_line_is_header: true,     // Default: true
    delimiter: ',',                 // Default: ','
    enclosure: '"',                 // Default: '"'
    encoding: 'UTF-8'               // Default: 'UTF-8'
);
```

---

⚠️ Memory Safety
----------------

[](#️-memory-safety)

`csvToArray()` automatically estimates average memory per row and throws an exception if your PHP memory limit is about to be exceeded.

If you need to handle huge files, increase `memory_limit` in your `php.ini`, for example:

```
memory_limit = 512M
```

---

📦 Dependencies and Licenses
---------------------------

[](#-dependencies-and-licenses)

This package is licensed under the [MIT License](LICENSE.md).

It uses the following open-source libraries:

- [OpenSpout](https://github.com/openspout/openspout) – MIT License
- [Box/Spout](https://github.com/box/spout) – Apache License 2.0

---

🧑‍💻 Author
----------

[](#‍-author)

**Novak Urošević**GitHub: [@novakurosevic](https://github.com/novakurosevic)

---

License
-------

[](#license)

This package is licensed under the [MIT License](LICENSE.md).

It uses the following open-source libraries:

- [OpenSpout](https://github.com/openspout/openspout) – MIT License
- [Box/Spout](https://github.com/box/spout) – Apache License 2.0

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance76

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

131d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9f7b649b2e74379ec4f29aa4951f634dc9edc9c15711d3fe4cf090d845783a46?d=identicon)[noki](/maintainers/noki)

---

Top Contributors

[![novakurosevic](https://avatars.githubusercontent.com/u/17499419?v=4)](https://github.com/novakurosevic "novakurosevic (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/noki-large-csv-converter/health.svg)

```
[![Health](https://phpackages.com/badges/noki-large-csv-converter/health.svg)](https://phpackages.com/packages/noki-large-csv-converter)
```

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M125](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

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