Free Online PHP Array to JSON Converter
Convert PHP array literals to JSON with HubKit's PHP array to JSON converter. Paste a PHP array definition and get clean, valid JSON output. Ideal for migrating configuration data, creating API fixtures, or converting PHP data structures for use in JavaScript applications.
How to Use
Paste a PHP array literal using either [] shorthand or the array() syntax. The tool parses the PHP array and outputs equivalent JSON. Copy the JSON for use in your application.
Features
- Convert PHP array() and [] syntax to JSON
- Handle associative and indexed arrays
- Support for nested structures and mixed types
- Parse PHP safely without code execution
Frequently Asked Questions
What PHP array features does this tool support?
The tool supports both array() and [] shorthand syntax, string and integer keys, nested arrays, strings, numbers, booleans, and null values. PHP constants and expressions are not evaluated.
Is the JSON output valid and ready to use?
Yes. The output is well-formed JSON that can be used directly in JavaScript, REST APIs, configuration files, and any system that consumes JSON.
Can I convert JSON back to PHP arrays?
This tool converts PHP to JSON. For JSON to PHP, you can use json_decode() in your PHP code, which natively converts JSON to PHP arrays or objects.