JSON ↔ PHP array
Convert JSON to a PHP array literal with short or array() syntax, or turn a PHP array back into JSON. Runs in your browser; nothing is uploaded.
No account, uploads or PHP execution. Your inputs stay on this device.
How the conversion works
JSON objects become associative arrays with 'key' => value pairs, and JSON lists become lists. Keys that look like integers ("0", "42") are written as integers, because PHP casts them that way anyway. true, false and null map directly, and floats keep their decimal point.
In the other direction, the tool reads a PHP array literal: short [] or array() syntax, single or double-quoted strings with escapes, integers including hex, octal, binary and 1_000 separators, floats, booleans and null. You can paste a whole config file such as <?php return [ ... ]; or an assignment like $config = [ ... ];. It is parsed, never executed, so constants, function calls and variables are rejected with a message showing where.
Lists versus objects
A PHP array becomes a JSON list only when its keys are 0, 1, 2… in order; otherwise it becomes an object. That is the same rule json_encode() uses, explained with fixes in PHP array to JSON.
Doing the same in PHP
$array = json_decode($json, true, flags: JSON_THROW_ON_ERROR);
echo var_export($array, true); // array ( 'name' => ... ) syntax
$json = json_encode($array, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR);var_export() always prints the long array ( syntax with its own spacing; this tool gives you short syntax and your choice of indentation, ready to paste into PSR-12 style code.