Loading PHP to JSON Converter...
How to Convert PHP to JSON
Paste a PHP array, press Convert, and get clean JSON back — with large IDs, leading zeros and decimals left exactly as you wrote them.
Paste your PHP code
Start with a PHP array, an associative array, or any data structure you want as JSON. Both array() and short [] syntax work.
Example: PHP Associative Array
A typical PHP array:
array(
'name' => 'Alex Morgan',
'age' => 32,
'isActive' => true,
'skills' => array('PHP', 'Laravel', 'MySQL')
)Press Convert
Press the green Convert button. Your PHP code is sent to our server, where an AI service reads the keys and values and writes the matching JSON.
Example: JSON Output
The same data as JSON:
{
"name": "Alex Morgan",
"age": 32,
"isActive": true,
"skills": [
"PHP",
"Laravel",
"MySQL"
]
}Read the JSON
The JSON shows up in the output panel. You can run it through the JSON validator if you want to double-check it.
Copy or download
Copy the JSON to your clipboard or save it as a .json file.
What is PHP to JSON conversion?
It takes PHP data — arrays, associative arrays and their values — and writes them out as JSON, the format most APIs and tools expect for data exchange. That makes it easy to move PHP data into a config file, a log line, or a web payload without hand-editing it.
Going the other way? The JSON to PHP converter rebuilds PHP arrays from JSON. You can also convert other languages, like Python to JSON, JavaScript to JSON, or Java to JSON.
Frequently Asked Questions About PHP to JSON Conversion
How do I convert a PHP array to JSON?
Paste your PHP array — either array() or short [] syntax — and press Convert. Your code is sent to our server, where an AI service reads the keys and values and writes the matching JSON. The result shows up in the output panel, ready to copy or save as a .json file.
Does it handle nested arrays and associative arrays?
Yes. An associative array becomes a JSON object, a plain indexed array becomes a JSON array, and nested arrays carry their structure through. For the other direction, the JSON to PHP converter rebuilds PHP arrays from JSON.
Which PHP values does it understand?
Arrays written with array() or [], the => key arrow, strings, integers and floats, and the literals true, false and null. They map to JSON objects, arrays, strings, numbers, booleans and null.
Are large numbers and leading zeros kept exactly?
Yes. A value like 8901240544102066246, a zip code written as "00501", or a price of 14.50 comes back exactly as written. The JSON is re-indented in your browser without re-reading the numbers, so nothing is rounded or re-spelled.
Where does my PHP code go, and is any of it kept?
The code is sent to our server, where an AI service does the conversion, so leave out passwords or private keys. It is processed there and nothing is stored — reloading the page starts with an empty editor.
Is the PHP to JSON converter free?
Yes, it's free and there's no sign-up. Because an AI service does the work, converting large or unusual PHP can take a few seconds.
Related Tools
JSON Serialization
Serialize any code or data to JSON format
JSON Deserialization
Deserialize JSON to code in any programming language
C to JSON
Convert C structs and code to JSON format
C++ to JSON
Convert C++ classes, structs, and STL containers to JSON format
C# to JSON
Convert C# objects and classes to JSON format
Python to JSON
Convert Python dictionaries and objects to JSON format