JSON to PHP array





This tool allows you to convert json to php array, object or associative array. You can mix array with objects.

A user guide is available below to help you use this converter.

User guide

To convert JSON data:

  • Drag and drop your JSON file or copy / paste your JSON text directly into the editors above.
  • As soon as the editor detects a valid JSON, it displays the php code.
  • In order to download the results you must click on "Download PHP" button.
  • You can also copy the PHP code to the clipboard by clicking on the button "Copy to clipboard".

This tool does not convert php array to json.

Above the editors, you can set the options:

  • Convert JSON object to: you have the choice between converting to objects or associative arrays

JSON to PHP converter

PHP is one of the most used languages even if it does not have the best reputation (you can write clean, fast and maintainable code in PHP ...).

JSON is a popular format that uses human-readable text. I prefer it to XML format.

PHP is a language which allows quite easily to manipulate data. Since JSON format is used a lot, chances are some people need to convert JSON data in order to use it in their PHP code. In PHP language, it is possible to use the json_decode function to convert JSON code to a PHP object / array. But it might be useful for someone to have their JSON data directly in their code (without conversion).
I do not know what the use cases are, but if you come across this page it must be useful for something :)

If you think of interesting features, which could be useful to other people, do not hesitate to add a comment to present them.

You can report a bug or give feedback by adding a comment (below) or by clicking "Contact me" link (at the top right hand corner of the page).