JSON ↔ PHP Array

Convert JSON to PHP array syntax or parse PHP arrays back to JSON, preserving key order like PHP does. Free online converter.

About this tool

Convert JSON to PHP array syntax and PHP arrays back to JSON. Both array() and [] syntax are parsed, including comments and trailing commas.

How to use

  1. Choose JSON → PHP or PHP → JSON.
  2. Paste the input; a leading <?php, return or $var = is allowed.
  3. Copy the output.

Frequently asked questions

Is key order preserved?

Yes. Integer-like keys keep PHP's insertion order instead of being reordered.

How are lists detected?

Arrays with keys 0, 1, 2… in order become JSON arrays; anything else becomes a JSON object.

Which PHP strings are supported?

Single- and double-quoted strings with their escape rules, including \u{…} in double quotes.

Related tools