How it works
PHP represents structured data with arrays, which combine lists and key-value maps. JSON is the universal format for exchanging that data between systems. This tool converts both ways: from PHP array to JSON and from JSON to PHP array.
It is equivalent to what json_encode and json_decode do in PHP, but without writing or running code: you paste the array or the JSON, or load a file, and get the result in the other format.
It recognizes PHP array syntax, including the short bracket form and the => operator, and produces ready-to-copy output. The whole process happens in your browser.
Examples
['name' => 'Ada', 'age' => 36]{ "name": "Ada", "age": 36 }From PHP array to JSON: the => operator becomes the : separator and single quotes become double quotes.{ "items": [1, 2, 3] }['items' => [1, 2, 3]]From JSON to PHP array: arrays are mapped to indexed arrays.Use cases
- Convert a PHP configuration array to JSON to use it in the frontend or an API.
- Turn a service's JSON response into a PHP array ready to paste into your code.
- Inspect a PHP array from a log by converting it to JSON, easier to read and validate.
Frequently asked questions
How is a PHP associative array converted?
An array with text keys ('name' => 'Ada') becomes a JSON object. An array with consecutive numeric keys from 0 becomes a JSON array.
What happens with an array of non-consecutive indices?
In PHP, an array whose numeric indices have gaps is not equivalent to a JSON array, so it is represented as an object with the numeric keys as strings. It is the same behavior as json_encode.
Does it accept the old array() syntax besides the brackets?
The recommended form is the short one with brackets [ ], standard since PHP 5.4. Write the array with that syntax to ensure a correct conversion.
Does it preserve the order of the keys?
Yes. Both PHP arrays and JSON objects keep the order in which the keys were written, and the conversion respects it.