PHP Array to JSON
runs in your browserno sign-upfree
Convert PHP array code (array() or [ ]) into formatted JSON, right in your browser.
Converted to JSON
About this tool
This tool converts PHP array code into JSON. It understands both array( ) and short [ ] syntax, single and double-quoted strings with escapes, numbers (including hex, binary and octal), true/false/null, comments and trailing commas. Lists become JSON arrays; arrays with keys become JSON objects.
How to use
- Paste PHP array code into the PHP box. A leading <?php, $variable = or return is fine.
- Choose the JSON indent.
- Copy the JSON or download it as a .json file.
FAQ
Is the result the same as json_encode?
Yes for normal data: arrays with keys 0, 1, 2… become JSON arrays and everything else becomes JSON objects, like json_encode. Keys are auto-numbered the same way PHP does.
Can it convert variables, constants or function calls?
No. Only literal values can be converted. If the code contains a variable, the status line points to it.
Is my data uploaded or run as PHP?
No. The conversion happens in your browser with a small JavaScript parser — no PHP is executed and nothing is uploaded.