Free browser-based tool

JSON and PHP Array Converter

Convert nested JSON to modern or legacy PHP array syntax and safely parse supported PHP scalar arrays back to JSON without executing code.

Guide

Convert nested JSON and supported PHP arrays without eval

JSON objects map naturally to associative PHP arrays, while JSON arrays map to sequential PHP arrays. Strings, numbers, booleans, nulls, nested objects, and nested arrays are preserved.

The reverse parser accepts a deliberately limited PHP array grammar and never executes pasted PHP. Function calls, constants, expressions, object construction, and arbitrary code are rejected.

Common questions

JSON and PHP Array Converter FAQ

Does the PHP parser execute pasted code?

No. A purpose-built tokenizer and recursive parser accept only scalar values, array syntax, keys, assignments, return, comments, and nesting.

Are short and legacy PHP array formats supported?

JSON output can use modern square-bracket syntax or legacy array parentheses. The reverse parser accepts both.

Can every PHP array become identical JSON?

PHP supports key and ordering behavior that JSON does not represent identically. Sequential integer keys become JSON arrays; other keys become JSON object properties.

Related tools

Continue working with your data

All tools