JSON to PHP
Generate plain PHP associative arrays from any JSON document.
Generate a PHP array
Result: —
How to use the JSON to PHP
- Paste a JSON document into the input box.
- Set the PHP variable name for the generated array.
- Click Generate PHP and copy the escaped array code.
Features
- Short array syntax with string keys
- Quotes and backslashes escaped in every string
- Nulls and booleans stay real PHP values
- A comment block lists the inferred types
Advertisement
Frequently Asked Questions
Common questions about the free online json to php.
Paste a JSON document, set the variable name and click Generate PHP. The structure is written
as nested PHP arrays you can paste into your code.
Short array syntax with string keys is used, and string values are single quoted, so the
output works in any PHP 5.4 or newer project.
Nested objects become nested associative arrays, and arrays of objects become indexed arrays
that hold one associative array per item.
Single quotes and backslashes inside string values are escaped with a backslash, so your text
cannot break out of the string literal.
Nulls are written as null and booleans as true or false, so real PHP values are created
instead of quoted text.
Yes. A short comment lists the inferred type of every object and the fields it contains,
based on the key path naming rules.
No. Everything is generated locally in your browser, so your data never leaves your device.
Text that is not valid JSON, or an empty input box, produces a clear error message instead of
partial code.
Last updated: October 10, 2026