JSON to PHP Array Converter

Convert JSON to a PHP return file with exact 64-bit integer literals, safe string quoting and optional object preservation.

Export PHP data without running it

Paste JSON and download a PHP file that returns its value. Strings use single quotes, escape backslashes and quotes, and represent control characters with chr(). Dollar signs remain literal text. No input is evaluated as PHP or JavaScript.

Associative-array mode converts JSON objects and arrays to PHP arrays; an empty object becomes []. Numeric-looking object keys follow PHP array-key coercion. Choose stdClass mode to preserve the distinction between objects and arrays, including empty objects and numeric property names.

Precision and runtime

Integer literals must fit signed 64-bit PHP integers. Use a 64-bit PHP runtime; 32-bit PHP has a smaller integer range. Decimal literals use PHP floating-point arithmetic and may round. The tool rejects overflow, underflow, duplicate JSON keys, more than 200,000 input characters or 64 levels. JSON data is stored as data, not executable statements.

Questions & answers

Can empty objects survive conversion?

Yes. Select stdClass objects to emit (object) [] instead of an empty associative array.

Will $name or PHP tags in a JSON string execute?

No. They are encoded inside a quoted PHP string. The tool never executes generated PHP. Review the data and include the downloaded file only in your own trusted application.

Other Languages

JSON to PHP Array Converter — Base64.sh

JSON to PHP Array Converter

Convert JSON to a PHP return file with exact 64-bit integer literals, safe string quoting and optional object preservation.

Share:

References

How we make sure

We check this tool with the automated test suites linked below. Example checks are shown in their original language.

Verification method
Parse generated PHP and check exact large-integer tokens, safe strings and object/array choices.
Comparison reference
php-parser and explicit PHP source assertions.
Verification scope
These samples and boundaries do not prove correctness for every input.
Test source and cases (select a file to read it)
  • code-tools.test.js
    • JSON to PHP preserves exact integer tokens, safe strings and object/array choices in parsed PHP

These checks cover the listed examples and boundaries, not every possible input. Round trips and checks using the same library are not independent verification.