JSON to PHP Array
Convert JSON into ready-to-paste PHP array syntax — short [] or classic array(), with your preferred indentation.
Tool input is processed locally in your browser and is not submitted to CodeNimbleTools. Avoid pasting production secrets into any device or website you do not fully trust.
About this tool
Config files, seeders and fixtures often start life as JSON but need to live in PHP. This converter turns any JSON document into valid PHP array code — modern short syntax or classic array(), with 2-space, 4-space or tab indentation.
Strings are safely single-quoted and escaped, so the output drops straight into your project.
How to use it
- Paste JSON into the input.
- Pick short
[]or longarray()syntax. - Choose indentation and whether to include
$data =. - Copy or download as a
.phpfile.
Useful ways to apply it
- Converting a JSON config into a PHP config file.
- Building Laravel/Symfony seed data from API responses.
- Turning fixture JSON into PHPUnit test arrays.
- Migrating settings from a JS project to a PHP project.
Worked example
Example input
{"site":"CodeNimbleTools","features":["fast","private"],"active":true}
Expected output
$data = ['site' => 'CodeNimbleTools', 'features' => ['fast', 'private'], 'active' => true];
Edge cases to check
- JSON numbers do not encode PHP-specific integer/float range intent.
- Object keys and string values need PHP string escaping.
- A generated PHP literal does not validate an external payload before runtime use.
Known limitations
The converter maps JSON values to PHP array syntax; it does not create typed DTOs, classes, validators or application-specific hydration logic.
How this tool was reviewed
Reviewed with nested arrays/objects, quotes/backslashes, null, booleans and short/long array syntax.
Standards and technical references
See the site-wide testing methodology for fixture categories, privacy checks and correction policy.
Frequently asked questions
Are booleans and null converted correctly?
How are special characters escaped?
Can it handle deeply nested JSON?
Privacy
Tool input is processed locally in your browser and is not submitted to CodeNimbleTools. Avoid pasting production secrets into any device or website you do not fully trust.