Convert JSON to PHP
array, stdClass
or typed class.
Generate PHP associative arrays, stdClass objects or typed PHP 8 classes from any JSON sample. Nested objects, nullable types, constructor promotion. Runs entirely in your browser.
?mixed in typed class mode.
Three PHP output styles for three different use cases.
| Style | PHP version | Access syntax | Best for |
|---|---|---|---|
| Array | Any PHP version | $data['key'] |
Most common PHP pattern. Equivalent to json_decode($json, true). Works with array functions (array_map, array_filter, etc.). |
| stdClass | Any PHP version | $data->key |
When you prefer object syntax. Equivalent to json_decode($json) without the true flag. Properties accessed with ->. |
| Typed class | PHP 8.0+ | $obj->getName() |
Modern PHP with strict typing. Constructor promotion, typed properties, IDE autocompletion. Best for domain models and DTOs. |
| JSON value | PHP type | Notes |
|---|---|---|
"Alice" | string | All JSON strings become string. |
42 | int | JSON integers become int. |
98.5 | float | JSON floats become float. |
true | bool | Direct mapping. |
null | ?mixed | Null fields become nullable mixed — refine manually after generating. |
["a","b"] | array<string> | Item type inferred from first element. Empty → array<mixed>. |
[{…}] | array<ChildClass> | Array of objects → separate class + typed array. |
{…} | ChildClass | Nested object → separate named class. |
Laravel and Symfony apps consume REST APIs and receive JSON payloads. Generate the PHP array or typed class from the API response JSON — then use it directly in your controller, service or repository. For Laravel, the typed class works perfectly as a DTO for FormRequest or API Resource output.
PHP config files are often arrays. Convert a JSON configuration file to a PHP array to use in a config/services.php or similar file — keeping JSON as the source of truth while generating the PHP equivalent for frameworks that require native PHP arrays.
PHPUnit tests need PHP arrays or objects that match your API response structure. Generate the PHP array from a real API response JSON — then use it as the expected value in your assertions or as the mock return value for a repository stub.
Integrating a payment gateway, shipping provider or CRM API? Generate typed PHP classes from the API documentation JSON examples — giving you IDE autocompletion, static analysis with PHPStan or Psalm, and type safety across the integration layer.
PHP generated in
your browser. No upload.
The entire PHP generation runs in JavaScript locally. Your JSON is parsed and traversed entirely in your browser — it is never transmitted to any server. The generated code follows PHP 8 conventions: constructor promotion, typed properties, nullable syntax and array type hints.
The Array output is identical to what json_decode($json, true) returns at runtime — a nested associative array you can use with array functions, pass to views or store in session without any class instantiation.
