JSON to PHP Array
Convert JSON into a PHP array literal with short [] syntax, ready to paste into a Laravel config file, a seeder or a test.
Free · No sign-up · Your inputs stay in your browser
Input
Convert JSON to a PHP array
Output
PHP
491 characters
Strings are single-quoted, so $ and \n inside them stay literal, matching what json_decode($json, true) would give you at runtime. Laravel config files and seeders use exactly this shape.
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
Same data as json_decode()
The output is what json_decode($json, true) returns at runtime, written out as source. Integer-looking object keys such as "1" become integer keys, as PHP does with any numeric string key. Without true, json_decode() returns stdClass objects instead; config files and seeders want arrays.
Where this is handy
Laravel config files return a PHP array, factories and seeders define rows as arrays, and test fixtures are easier to read as PHP than as an embedded JSON string. For large fixtures, keep the JSON in a file and decode it in the test instead: json_decode(file_get_contents(__DIR__.'/fixture.json'), true).