Structured Data

JSON to PHP Array

Paste JSON and get readable PHP array syntax — a $data = [...] assignment, a return [...] statement, or the bare array literal. Choose indentation, array style and quoting, then copy or download. Everything runs in your browser.

Runs in your browser v1.0.0

Output format

updates live

Use letters, digits or underscores. It cannot start with a digit. The dollar sign is added for you.

Assign the array to a variable — the usual way to drop JSON into a PHP script.

Formatting options
Pretty output

JSON input

never uploaded

Parsed with the browser’s own JSON parser. Invalid input is reported with a line and column instead of a broken state.

PHP output

ready


                

How it works

Your input is parsed with JSON.parse() in this page and re-serialized as PHP array literals. JSON objects and arrays both become PHP arrays, object keys are written as 'key' => value, and strings are escaped for the quote style you choose. Because both JSON containers map to the same PHP type, an empty object and an empty array both become []. The output is plain PHP and is never executed. Numbers keep the value the browser parsed, so extremely large integers may already have been rounded. Nothing is sent to a server; the optional share link keeps the state in the URL fragment, which never leaves your browser.