What does this tool do?
JSON to PHP Array converts the JSON you paste into a ready-to-use PHP array code block. The output uses modern short-array syntax ([]) with 'key' => value pairs, making it ideal for PHP developers, WordPress plugin authors, and anyone building configuration files.
How to use it
- Paste or type your data into the left field.
- The result is generated instantly on the right.
- Use the Copy button to grab the output.
How the output is formatted
The tool emits the whole structure using PHP's short-array syntax ([]) instead of the older array() construct. Each level is indented with four spaces, strings are wrapped in single quotes, and backslashes and single quotes are escaped automatically. A JSON null becomes null, while true and false map straight to PHP booleans. The output is prefixed with a <?php tag and a $data variable, so you can paste it into a file and use it immediately.
Objects versus indexed arrays
JSON objects ({}) are converted into associative PHP arrays with key => value pairs, while JSON arrays ([]) become sequential indexed arrays. In PHP both are the array type, so deeply nested data is preserved at any depth without losing structure. This makes it a fast way to embed an API response or config payload directly into PHP source code.
Frequently asked questions
Does the output use array() or the short [] syntax?
It uses the modern short-array syntax ([]), which is supported in PHP 5.4 and later and is the recommended style today.
Will single quotes and backslashes in my strings break the code?
No. Single quotes and backslashes are escaped automatically, so the generated PHP stays valid and parseable.
How are JSON true, false, and null represented?
They map directly to PHP's true, false, and null, written as real booleans and null rather than quoted strings.
Is JSON to PHP Array free?
Yes. JSON to PHP Array and all 300+ tools on MagmaNex are completely free with no signup or account required.
Is my data safe?
Yes. Everything runs locally in your browser. The data you enter is never sent to a server, stored, or shared.
Does it work on mobile?
Yes. JSON to PHP Array works on phones, tablets and desktops — no app download needed.
🔒 Privacy: everything runs in your browser, your data is never sent to a server.
