PHP Array to JSON Converter

Paste a PHP array - short [] syntax or array(), nested as deep as you like - and get valid JSON back.

Detected: PHP array
Input (auto-detected)
Convert to
💡 Pro tip: PressKto quickly search and navigate between tools

Examples & Use Cases

  • Before:

    A nested array of settings written with => arrows, which is not something any JSON validator or API client will take.

  • After:

    The same settings as formatted JSON, ready for a config file, an API request or a front-end that expects JSON.

No throwaway PHP script needed just to call json_encode() once.

A config array that has to become JSON
Laravel and WordPress projects keep a lot of configuration in PHP arrays that eventually needs a JSON equivalent.
  • Before:

    Pages of array ( ... ) with mixed indentation and numeric keys, printed into a log or a browser response.

  • After:

    Clean JSON with the structure visible, which you can then fold and search in any JSON viewer.

Makes a dump readable without editing it by hand.

Reading a var_export() dump
Debug output from var_export() is accurate but painful to read once it is more than a few levels deep.

Frequently Asked Questions

The result is, for the cases above - but json_encode() needs the array to exist inside a running PHP process. This works on the array as text, so you can convert something pasted from a config file, a var_export() dump or a Stack Overflow answer without setting up PHP.