Skip to main content
Programming Language Tools

PHP Array to JSON

Convert a PHP array literal into valid JSON.

Paste a PHP array literal below - this tool converts it into valid, formatted JSON.

Going the other direction? Use the JSON to PHP Array converter instead.

What Does This Tool Do?

It parses PHP array syntax (['key' => 'value'] or the older array('key' => 'value') form, including nested arrays) and converts it into equivalent JSON.

Why Use This Tool?

Useful when you have PHP configuration or test data and need the equivalent JSON - for an API response mock, a JavaScript test fixture, or documentation.

How to Use It

  1. Paste a PHP array literal.
  2. Click Convert.
  3. Copy the resulting JSON.

Limitations

This handles array literals containing plain values (strings, numbers, booleans, null, nested arrays) - PHP-specific constructs like object instances, constants, or function calls within the array aren't representable in JSON and won't convert.

Share this tool: