JSON to PHP Array

Convert JSON into ready-to-paste PHP array syntax — short [] or classic array(), with your preferred indentation.

This tool runs 100% in your browser. Your data is never uploaded, stored, or logged.

PHP array

  

About this tool

Config files, seeders and fixtures often start life as JSON but need to live in PHP. This converter turns any JSON document into valid PHP array code — modern short syntax or classic array(), with 2-space, 4-space or tab indentation.

Strings are safely single-quoted and escaped, so the output drops straight into your project.

How to use it

  1. Paste JSON into the input.
  2. Pick short [] or long array() syntax.
  3. Choose indentation and whether to include $data =.
  4. Copy or download as a .php file.

Useful ways to apply it

  • Converting a JSON config into a PHP config file.
  • Building Laravel/Symfony seed data from API responses.
  • Turning fixture JSON into PHPUnit test arrays.
  • Migrating settings from a JS project to a PHP project.

Frequently asked questions

Are booleans and null converted correctly?
Yes — true, false and null become PHP true, false and null literals, not strings.
How are special characters escaped?
Output uses single-quoted PHP strings, so only backslashes and single quotes are escaped. Everything else stays literal.
Can it handle deeply nested JSON?
Yes, nesting is unlimited and indentation stays consistent at every level.

Privacy

This tool runs 100% in your browser. Your data is never uploaded, stored, or logged.