Cette page n’est pas encore traduite en français : elle s’affiche en anglais.

Excel, CSV & JSON to PHP Array Converter

Turn spreadsheet rows or JSON into a ready-to-paste PHP array for config files, seeders, fixtures and Laravel or WordPress code.

Mis à jour le
Open file (.xlsx, .csv, .json)
Input
Shape
Indent

Input preview

Vos données ne quittent jamais votre ordinateur. Tout le traitement se fait localement dans votre navigateur.

Comment utiliser : Excel, CSV & JSON to PHP Array

  1. Paste CSV, Excel cells or JSON, or open a file.
  2. Choose the shape: associative arrays (one per row), plain row lists, or an array keyed by the first column.
  3. Pick short [] or classic array() syntax, the variable name or return, and the indentation.
  4. Copy the PHP code or download it as a .php file.

What does this PHP array converter do?

It turns tabular data or JSON into a PHP array literal you can paste into source code. That is useful for configuration files that return an array, database seeders, unit-test fixtures, lookup tables (countries, currencies, product SKUs) and WordPress or Laravel code that ships with static data.

<?php

$data = [
    [
        'id' => 1,
        'name' => 'Ada Lovelace',
        'active' => true,
    ],
];

Array shapes

ShapeOutputTypical use
Associative[['id' => 1, 'name' => 'Ada'], …]Seeders, foreach loops, inserting rows
Rows (lists)[['id', 'name'], [1, 'Ada'], …]fputcsv(), compact storage
Keyed by 1st column['1' => ['id' => 1, …], …]Fast lookups: $users[$id]

When the input is JSON, Keep original JSON structure converts it as-is — nested objects become nested associative arrays, exactly like json_decode($json, true) would produce.

Escaping and types

  • Strings use single quotes, the fastest and safest PHP string form: only \ and ' need escaping, and $variables are never interpolated.
  • Numbers, true/false and null are written as PHP literals, not strings.
  • Values with leading zeros ("007") stay strings so nothing is lost.

Short [] vs array()

The short array syntax [] has been available since PHP 5.4 and is the standard in PSR-12 and modern frameworks. Choose array() only for very old codebases or coding standards that still require it. Trailing commas after the last element are valid in all PHP versions and keep diffs clean.

Need the same data for front-end code? Use CSV to JavaScript array. Going to a database instead? Try CSV & Excel to SQL.

Aussi recherché comme : json to php array, csv to php array, excel to php array, php array generator, convert json to php, php array from csv, laravel seeder array.

Outils complémentaires : Excel, CSV & JSON to PHP Array

  • Excel to JSON — Open an .xlsx workbook or paste cells straight from Excel or Google Sheets and get clean JSON.
  • Formateur JSON — Collez votre code JSON pour le formater, le compresser ou le valider.
  • CSV to JSON — Paste CSV or TSV and get a JSON array of objects.
  • JSON to Excel — Turn a JSON array into a real Excel workbook.

Questions fréquentes

How do I convert JSON to a PHP array?
Paste the JSON and keep Keep original JSON structure ticked. The output is the PHP array literal that json_decode($json, true) would return.
Should I use [] or array()?
Use the short [] syntax unless you support PHP older than 5.4. It is shorter and recommended by PSR-12.
Can I create a config file that returns an array?
Yes. Choose return [...]; and keep the <?php tag — this is the format Laravel and many other frameworks use for config files.
Are my files uploaded?
No. Everything is converted locally in your browser.
Puis-je installer Excel, CSV & JSON to PHP Array en tant qu’application web et l’utiliser hors ligne ?
Oui. Excel, CSV & JSON to PHP Array est une application web installable (PWA) : elle s’installe depuis votre navigateur, sans passer par une boutique d’applications. Cliquez sur « Installer l’application » en haut de cette page dans Chrome ou Edge (Windows, macOS, Linux, ChromeOS) ; sur Android, utilisez « Partager » → « Ajouter à l’écran d’accueil » sur iPhone et iPad ; ou « Fichier » → « Ajouter au Dock » dans Safari 17+ sur Mac. L’application s’ouvre alors dans sa propre fenêtre avec sa propre icône, et comme elle s’exécute entièrement dans votre navigateur, elle continue de fonctionner hors ligne. Firefox sur ordinateur de bureau ne permet pas d’installer d’applications web. Comment fonctionne l’installation.

Outils similaires