Developer tools

JSON to PHP

Turn JSON into a PHP array expression with safely quoted strings.

JSON to PHP
Esc to restore

Your inputs

Up to 200,000 characters. Source is processed locally and never executed.

Results update as you type. Larger files run when you press Update result.

Your result

Your result will appear here.

More actions

Your inputs stay in this browser. Nothing is uploaded or saved.

A clear answer. Here’s how.

Reads JSON and emits a PHP short-array expression with a terminating semicolon. Object keys become PHP array keys, so canonical numeric string keys become integers and an empty object becomes an empty PHP array. Strings use single-quoted PHP syntax with backslashes and quotes escaped. Arrays retain order. Numbers use JavaScript finite numbers and unsafe integers are refused. This is a data expression, not a full PHP script or an object/class generator. Up to 200,000 characters, 20,000 values and 64 levels.

How this is checked

2 reference checks passed These 2 cases were run when this page was built, on 3 December 2026, and all reproduce within the stated tolerance. The same cases are part of the automated tests that run on every change to Toolmoz. Engine version 1.

See the checks and where each expected answer comes from
  1. Case 1

    Inputs
    Source {"x":1}
    Expected, and what Toolmoz gave
    text expected [ 'x' => 1 ]; , Toolmoz [ 'x' => 1 ];
    Where the expected answer comes from
    A one-property JSON object becomes a one-entry PHP associative array.
    Allowed difference
    exact
  2. Case 2

    Inputs
    Source [true,null,"x"]
    Expected, and what Toolmoz gave
    text expected [ true, null, 'x' ]; , Toolmoz [ true, null, 'x' ];
    Where the expected answer comes from
    A JSON list becomes an unkeyed PHP array with boolean, null and quoted string literals.
    Allowed difference
    exact

What this shows: the engine reproduces independently worked values for these cases. It does not prove every possible input is right. To test an answer you were given, see how to check a number; to see what is and is not checked across Toolmoz, see the accuracy ledger.

See a worked example

Worked example

A fixed demonstration, separate from the values you enter above.

Source
{"name":"Café","enabled":true,"tags":["web","api"]}
Indent
2 spaces

Example result

[
  'name' => 'Café',
  'enabled' => true,
  'tags' => [
    'web',
    'api'
  ]
];