JSON to PHP

Generate plain PHP associative arrays from any JSON document.

Generate a PHP array

Result: —
The output uses short array syntax, escapes quotes and backslashes, and keeps null and boolean values as real PHP values.

How to use the JSON to PHP

  1. Paste a JSON document into the input box.
  2. Set the PHP variable name for the generated array.
  3. Click Generate PHP and copy the escaped array code.

Features

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