JSON ⇄ PHP Array Converter
Convert JSON to PHP Array and vice versa. State is saved locally.
When working between PHP backends and JSON-based APIs or frontends, you often need to convert data between JSON format and PHP array syntax. This tool converts JSON objects and arrays to PHP associative array syntax and vice versa — supporting any level of nesting. All conversion happens instantly in your browser without any server interaction.
How to Use
- 1
Choose conversion direction
Select "JSON to PHP" or "PHP to JSON" using the Switch Direction button. The input and output labels update accordingly.
- 2
Paste your input
Paste your JSON object or PHP associative array into the left input panel.
- 3
View the converted output
The converted result appears instantly in the right panel as you type, with proper formatting and indentation.
- 4
Copy the result
Click the copy button to copy the converted output to your clipboard.
Features
Bidirectional Conversion
Convert JSON to PHP array and PHP array to JSON in both directions with a single click.
Nested Structure Support
Handles deeply nested objects, associative arrays, indexed arrays, booleans, nulls, and numbers.
Real-Time Conversion
Output updates instantly as you type — no button click required.
Local State Persistence
Your last input and mode are saved in localStorage and restored on your next visit.
Frequently Asked Questions
- What is the difference between JSON and a PHP array?
- JSON uses curly braces {} for objects, square brackets [] for arrays, colons : for key-value pairs, and double quotes for strings. PHP arrays use array() or [] notation with => for key-value pairs and single or double quotes for strings.
- Can this tool handle nested PHP arrays?
- Yes. The converter handles any depth of nested objects and arrays, including mixed associative and indexed arrays.
- Does this support the old PHP array() syntax?
- Yes. The PHP-to-JSON parser supports both the modern [] short array syntax and the legacy array() function syntax, as well as PHP comments (//, /* */, #).
- Is this tool useful for Laravel or Symfony development?
- Yes. PHP arrays are used extensively in Laravel config files, Eloquent model attributes, and response transformers. This tool helps quickly convert JSON API responses to the PHP array format needed in your backend code.