JSON to PHP Array
About the JSON to PHP Array
Turn a JSON object or array into PHP code you can paste straight into a config file, a test fixture or a seeder. The output uses short [] syntax with => between keys and values, and four-space indentation.
How to use it
- 1 Paste JSON into the Input JSON pane.
- 2 Read the PHP short array in the output pane; it updates as you type.
- 3 If the JSON is invalid, fix the error shown in the output pane.
- 4 Click Copy and paste the array into your PHP code.
Frequently asked questions
Objects become associative arrays and JSON arrays become lists. Strings are single-quoted and escaped, numbers stay integers or floats, and true, false and null keep their PHP spelling.
Short [] syntax only, the style used in modern PHP and Laravel code. Each nested level is indented by four spaces and every item ends with a trailing comma.
Both {} and [] become an empty PHP array, [], because PHP uses arrays for both lists and key-value maps.
Input is limited to 100,000 characters and 512 levels of nesting. Larger or deeper documents are refused with a message instead of being cut short.