JSON to PHP Array Converter
Convert JSON into a PHP array literal in one click, with array() or short [] syntax, configurable indentation and proper string escaping.
About This Tool
The JSON to PHP array converter outputs PHP array literals from standard JSON, removing the tedious work of rewriting quotes and arrows by hand. Choose the classic array() syntax or the short [] form and set the indentation width to match your project conventions.
Backslashes and single quotes inside strings are escaped automatically, while numbers, booleans and null keep their literal types so true never becomes the string "true".
Key Features
Two array syntaxes
Supports array() and [] for legacy and modern code styles.
Configurable indentation
2, 4 or 8 spaces to align with your code standards.
Correct escaping
Backslashes and single quotes are escaped, avoiding invalid PHP output.
Type fidelity
Numbers, booleans and null remain literals and are never stringified.
When to Use It
Config migration
Convert frontend JSON config into a PHP array for backend settings.
Persist API data
Turn third-party JSON into a PHP structure quickly during integration.
Prepare test fixtures
Convert JSON samples into PHP arrays for unit test fixtures.
How to Use It
- 1Paste JSON content.
- 2Choose the array syntax and indentation width.
- 3Click Convert to PHP.
- 4Copy the generated code into your project.
Frequently Asked Questions
Will Chinese characters be garbled?
No. They are output as-is, just keep the PHP file saved as UTF-8.
Does it handle nested structures?
Yes, any level of objects and arrays is supported and the output is indented by depth.
