450+ free calculators — no sign-up, no ads, no paywalls. Browse all tools →
Start typing to search...
Accurate JSON value conversion

JSON to PHP Array Converter

Transform valid JSON into clean, executable PHP array syntax. Preserve nested objects, indexed arrays, Unicode strings, numbers, booleans, and null values without uploading your data.

  • Complete value preservation
  • Private browser processing
  • Copy or download PHP
JSON to PHP Array Workspace
JSON input
PHP array output0 bytes

How to convert JSON to a PHP array

Create formatted PHP data in three straightforward steps.

01

Add valid JSON

Paste JSON into the editor or open a local .json file containing an object, array, string, number, boolean, or null.

02

Choose PHP syntax

Select modern square brackets or classic array() syntax and enter a safe variable name for the generated assignment.

03

Export the result

Review the formatted array, copy it into your project, or download a complete executable .php file.

Built for dependable PHP data conversion

The converter preserves JSON structure and values while producing readable, project-ready PHP.

Nested structures

JSON objects become associative arrays while JSON lists remain zero-indexed PHP arrays.

Unicode safe

International text, emoji, apostrophes, backslashes, and control characters are escaped correctly.

Two syntax styles

Use concise [] syntax for modern PHP or generate compatible classic array() notation.

Local processing

Parsing, formatting, copying, and downloading all happen inside your browser.

How JSON maps to PHP values

JSON objects become associative arrays with string keys. JSON arrays become indexed arrays. Strings remain quoted strings, numbers stay numeric, and true, false, and null map directly to PHP.

Correct string escaping

The generator uses single-quoted PHP strings and safely escapes apostrophes, backslashes, line breaks, tabs, and control characters without damaging Unicode text.

Ready to execute

The downloaded file contains the PHP opening tag and a valid variable assignment ending with a semicolon. Review untrusted data before using it in security-sensitive code.

// JSON
{
  "id": 42,
  "name": "Alex",
  "roles": ["admin", "editor"]
}

// PHP
$data = [
  'id' => 42,
  'name' => 'Alex',
  'roles' => ['admin', 'editor'],
];

JSON to PHP Array converter FAQs

Practical answers about PHP syntax, values, files, and privacy.

Does it support deeply nested JSON?

Yes. Objects and arrays are converted recursively while preserving their original hierarchy.

What is the difference between [] and array()?

Both create PHP arrays. Square brackets are the modern concise syntax, while array() supports older PHP versions.

How are JSON objects converted?

Object property names become quoted associative-array keys followed by the PHP double-arrow operator.

Are booleans and null converted correctly?

Yes. JSON true, false, and null values become matching lowercase PHP literals without quotation marks.

Are Unicode and emoji preserved?

Yes. Unicode remains readable, while characters that could break a PHP string are escaped safely.

Can the top-level JSON be a primitive?

Yes. A string, number, boolean, or null can be assigned directly to the selected PHP variable.

Is my JSON uploaded to the server?

No. Conversion happens locally in your browser and your JSON is not submitted to the server.

Is the downloaded file executable PHP?

Yes. It contains an opening PHP tag and a complete variable assignment. Always inspect external data before production use.