PHP Array to JSON Converter
Transform any PHP array syntax into valid JSON. Supports both short ([...]) and long (array(...)) array syntax. Handles associative arrays with string keys, indexed arrays, nested arrays, and mixed types. Booleans are parsed from true/false, null from null. The output is properly indented JSON.
Use Cases
- Config Migration — Convert PHP config files to JSON format
- API Development — Transform PHP array responses to JSON payloads
- Data Portability — Move from PHP-based config to JSON-based config
- Cross-Language — Share PHP data structures with non-PHP applications
Example
Input:
<?php
return [
'app' => [
'name' => 'MyApp',
'version' => '1.0.0',
'debug' => false,
'servers' => ['192.168.1.1', '192.168.1.2'],
'database' => [
'host' => 'localhost',
'port' => 5432,
],
],
];Output:
{
"app": {
"name": "MyApp",
"version": "1.0.0",
"debug": false,
"servers": ["192.168.1.1", "192.168.1.2"],
"database": {
"host": "localhost",
"port": 5432
}
}
}