JSON to PHP array converter
Paste JSON and get the PHP array that json_decode($json, true) would build, ready for config files and tests.
Loading the tool…
Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.
How to use it
- Enter json and array syntax.
- The result appears straight away and updates as you edit.
- Copy the result, or copy a link that keeps the same values to share it.
How it is calculated
Each object becomes an associative array of 'key' => value pairs, each array becomes an indexed list, true, false and null stay as PHP constants, and numbers keep their exact text. Strings are single-quoted with \ and ' escaped; strings with control characters use double quotes.
Example
Inputs: Array syntax = Short [ ]. Result: PHP array: [ 'name' => 'Ali', 'age' => 30, 'active' => true, 'tags' => [ 'admin', 'editor' ], 'address' => [ 'city' => 'Riyadh', 'zip' => null ] ]; Values converted: 7.
{
"name": "Ali",
"age": 30,
"active": true,
"tags": ["admin", "editor"],
"address": {
"city": "Riyadh",
"zip": null
}
}[
'name' => 'Ali',
'age' => 30,
'active' => true,
'tags' => [
'admin',
'editor'
],
'address' => [
'city' => 'Riyadh',
'zip' => null
]
]Limits and caveats
- An empty object {} becomes [] because PHP arrays cannot tell the two apart.
- Integers above PHP_INT_MAX are copied as written, but PHP reads them as floats.
Questions about this tool
Is the result the same as json_decode?
Yes. It is the array json_decode($json, true) returns: objects become associative arrays and lists become indexed arrays.
What is the difference between [ ] and array( )?
They mean the same thing. The short syntax exists since PHP 5.4 and is the common style; array( ) suits older codebases.
Why are some strings in double quotes?
A string with a line break or control character is double-quoted so escapes like \n work, and $ is escaped so it is not read as a variable.
