PHP Array to JSON Converter
Convert a PHP array literal, a Laravel config file or var_export() output to JSON, with short and long array syntax and nested arrays of any depth.
Free · No sign-up · Your inputs stay in your browser
Input
Convert a PHP array to JSON
Output
JSON
241 characters
Short [ ] and long array( ) syntax, nested to any depth, with true, false and null in any case. A sequential array from 0 becomes a JSON list and anything else an object, the same rule json_encode() uses. Function calls such as env() cannot be evaluated: replace them with their values first.
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
Lists versus maps
PHP has one array type for both, so the converter has to decide, and it decides like json_encode(): sequential integer keys from zero make a list, anything else makes an object. An array with keys 1, 2, 3 therefore becomes an object, which surprises people converting data that was filtered with array_filter(); array_values() re-indexes it.
Function calls are not evaluated
Laravel config files call env() and helpers such as storage_path(). Those calls cannot be resolved outside the application, so replace them with their values, or run php artisan config:show app --json, which prints a resolved section of the configuration.


