JSON to PHP Array Converter

Paste JSON and get a PHP array literal in modern short [] syntax, ready to paste into your code.

Detected: JSON
Input (auto-detected)
Convert to
💡 Pro tip: PressKto quickly search and navigate between tools

Examples & Use Cases

  • Before:

    Wrapping the JSON in json_decode('...', true) with the quoting escaped by hand, which is fiddly and re-parses the string on every run.

  • After:

    A plain PHP array literal with the same structure, which reads better in a diff and costs nothing at runtime.

Particularly useful for Laravel seeders and PHPUnit data providers.

An API sample becoming a PHP fixture
You have JSON from the API docs and you need it as a PHP value in a test or a seeder.

Frequently Asked Questions

json_decode() gives you a value at runtime. This gives you the literal to write into your source - handy for a config file, a fixture, a seeder or a default value where you do not want to parse a string every time the file loads.