JSON to PHP Array

Convert JSON objects and arrays into clean PHP array syntax.

JSON input
Waiting for JSON input
Empty0 lines0 B
PHP array output
Valid PHP output appears after conversion
PHP0 lines0 B
✓ Runs locally✓ No uploads✓ Nested arrays✓ Free forever
✓ PHP copied

Questions answered

JSON to PHP Array FAQs

How do I convert JSON to a PHP array?+

Paste, type, or upload valid JSON, choose short bracket syntax or classic array syntax, enter a PHP variable name, and select Convert. The generated PHP includes an opening PHP tag, a variable assignment, nested arrays, and correctly converted scalar values.

Should I use [] or array() syntax in PHP?+

Short bracket syntax is the modern, compact choice and works in PHP 5.4 and newer. Classic array() syntax is useful when maintaining older code or matching an established project style. Both formats represent the same PHP arrays and produce equivalent values at runtime.

How are JSON objects and arrays represented in PHP?+

JSON objects become associative PHP arrays with string keys and arrow operators. JSON arrays become indexed PHP arrays without explicit numeric keys. Nested values are converted recursively, while strings, numbers, booleans, and null become their corresponding PHP scalar values.

Is the JSON sent to a server for conversion?+

No. JSON validation and PHP generation happen locally inside your browser. Pasted data and uploaded files are not transferred to jsontoyaml.net or another service. You can copy the generated code or download it directly as a PHP file.