Output will appear here
Output will appear here
Generate PHP classes from JSON with typed properties, constructors, and PSR-12 compliant naming. This free JSON to PHP class generator creates production-ready code compatible with PHP 7.4+ including nullable types and PHPDoc annotations for IDE support.
Try Convert All - paste JSON once, see TypeScript, Go, YAML, and 15 more formats instantly.
Paste a JSON object or array into the editor. The converter processes nested objects, arrays, and all JSON primitive types including null values.
The output displays PHP classes with typed properties (PHP 7.4+), constructor initialization, and getter methods. Nested objects generate separate classes with proper type hints.
Copy the generated code into your project. Use json_decode() to parse raw JSON and then instantiate the classes with the decoded data for strongly typed access.
Paste your JSON into the converter and it generates PHP classes with typed properties, constructors, and getter methods. The classes use PHP 7.4+ property type declarations so your IDE provides autocomplete and your code benefits from runtime type checking.
Yes. The generated classes are plain PHP objects that work in any framework. In Laravel, you can use them alongside API Resources or Form Requests. In Symfony, they can serve as DTOs for the Serializer component.
The output uses typed properties which require PHP 7.4 or later. Constructor property promotion syntax is available if targeting PHP 8.0+. The generated code is compatible with all maintained PHP versions.
JSON arrays of primitives become array-typed properties with a PHPDoc @var annotation specifying the element type (e.g., @var string[]). Arrays of objects generate a typed class for the element and the property is annotated as @var ElementClass[].
The generated constructors accept the associative array returned by json_decode($json, true). Pass the decoded array to the constructor and all properties are populated with type-checked values, including nested objects which are recursively instantiated.