JSON to PHP Array Converter

Convert JSON to PHP array syntax instantly — ready to paste into your PHP code.

About JSON to PHP Array Conversion

PHP developers frequently need to convert JSON data into PHP array syntax — whether initializing configuration arrays, seeding test fixtures, hardcoding API mock data, or migrating JSON config files into PHP-based configurations. This tool does that conversion instantly and correctly.

The converter supports both PHP 5.4+ short array syntax (e.g., ['key' => 'value']) and the older array() syntax for compatibility with legacy codebases. JSON objects become associative PHP arrays with string keys, JSON arrays become indexed PHP arrays, and all JSON primitives are mapped to their PHP equivalents: strings with single quotes, numbers as-is, booleans as true/false, and null as null.

Strings are escaped using single quotes with proper backslash handling. The output is properly indented and ready to copy directly into your PHP files. You can also optionally wrap the output in a return statement for use as an include-based configuration file (a common PHP pattern).

Frequently Asked Questions

What's the difference between [] and array() syntax?
Both are functionally identical in PHP 5.4+. The short array syntax [] was introduced in PHP 5.4 and is now the modern preferred style. The array() syntax works in all PHP versions and may be required for legacy PHP 5.3 or older codebases.
How are JSON null values converted?
JSON null is converted to PHP null (lowercase). JSON true and false become PHP true and false respectively. These are the exact PHP equivalents of the JSON boolean and null types.
Are PHP reserved words handled as keys?
Yes. Since PHP associative array keys are always strings (quoted), there's no conflict with PHP reserved words. The keys are always output with single quotes, e.g., 'class' => 'foo'.