JSON to PHP Class
Generate PHP 8 classes with typed constructor property promotion from JSON. Each class becomes a value object you can hydrate from json_decode output. Drop into Laravel / Symfony / any PHP 8.1+ codebase.
How to use the JSON to PHP Class
Paste JSON. Output uses PHP 8 constructor promotion — fewer lines than the old getter/setter style. For PHP <8.0, expand into traditional property declarations + constructor body.
Generating PHP classes from JSON
Working with a decoded JSON array in PHP means string keys everywhere and no type safety — one typo in a key like $data['emial'] and you find out at runtime. Typed value objects fix that, but defining a class per object with proper property types is exactly the boilerplate PHP 8 was meant to cut down.
This generates PHP 8 classes with typed constructor property promotion from a JSON sample, so each object becomes a compact value object you can hydrate from json_decode output and drop straight into a Laravel, Symfony, or any PHP 8.1+ codebase. Nested objects become their own classes. For PHP versions before 8.0, expand the promoted constructor into traditional property declarations.
Common use cases
- Typed value objects — replace associative arrays with typed classes.
- Constructor promotion — get compact PHP 8 classes, not getter/setter boilerplate.
- Hydrate responses — build objects from
json_decodeoutput. - Framework ready — drop into Laravel, Symfony, or plain PHP 8.1+.
- Nested classes — generate a class for each nested object.