Boneyard Tools

JSON to PHP Array Converter

Paste JSON to get a ready-to-paste PHP array literal. Objects become associative arrays, arrays stay indexed, and strings are safely single-quoted.

How to convert JSON to a PHP array

  1. Paste or type your JSON into the box.
  2. Choose array() or short [] syntax and an indent width.
  3. Copy the PHP array and paste it into your code.

Examples

Object with a nested array

{"name":"Ada","tags":["dev","math"]}
array(
  'name' => 'Ada',
  'tags' => array(
    'dev',
    'math',
  ),
)

Frequently asked questions

Is my JSON uploaded anywhere?

No. The conversion runs entirely in your browser, so your data never leaves your device.

What is the difference between array() and short syntax?

They are equivalent in PHP 5.4 and later. Short syntax uses [ and ] instead of array( and ), which many style guides prefer.

How are JSON objects and arrays mapped?

JSON objects become associative PHP arrays with 'key' => value pairs. JSON arrays become indexed arrays with values only.

How are strings escaped?

Strings use single quotes, and any backslash or single quote inside is escaped, which matches how PHP single-quoted strings work.

How are true, false and null handled?

They map to the lowercase PHP keywords true, false and null. Numbers are emitted exactly as written in the JSON.

Related tools