PHP array and JSON converter
PHP array and JSON converter moves data between PHP and JSON in either direction.
What PHP array and JSON converter does
PHP array and JSON converter moves data between PHP and JSON in either direction. It is useful when you move settings from a PHP config file into a JavaScript app, or need a PHP array built from JSON data.
Paste a PHP array written with square brackets or array( ) and get formatted JSON. Paste JSON and get a PHP snippet with $data = [...] ready to use. Detect works out the direction for you. Strings, numbers, true, false, null, nested arrays, keys with => and comments are understood. A leading <?php tag and a $variable = part are skipped.
How to use PHP array and JSON converter
- Paste your data
Add a PHP array, or a JSON object or list.
- Check the direction
Leave it on Detect, or choose PHP to JSON or JSON to PHP.
- Press Convert
Copy the result or download it.
Questions about PHP array and JSON converter
How do I convert a PHP array to JSON?
Paste the array and press Convert. Arrays with keys become JSON objects, and simple lists become JSON lists.
Can it read PHP objects or function calls?
No. It reads array data only, and the error shows the place where it found something else.
Is my PHP code run?
No. The text is read as data and never run, and it stays in your browser.