JSON to PHP Array/Class
Convert JSON data to PHP class definitions with typed public properties. Support nested class generation, suitable for PHP 7.4+.
Input
Output
PHP array will appear here
What is JSON to PHP Array/Class?
JSON to PHP class tool can automatically generate PHP class definitions based on JSON data. Generated classes include typed public properties with type declarations (supporting PHP 7.4+ typed properties), and corresponding nested classes are generated for nested JSON objects. The tool automatically analyzes field types, generating correct type annotations for String, int, float, bool, array, etc. Code follows PHP coding standards and can be directly used in Symfony, Laravel, and other frameworks.
When to Use JSON to PHP Array/Class
Use when creating entity classes in PHP projects, generating Data Transfer Objects (DTOs) from API responses, building Laravel Eloquent model properties, or quickly setting up PHP backend data structures.
How to Use JSON to PHP Array/Class
Paste JSON data into the input area. Enter the root class name (optional, defaults to Root). Click the "Convert" button, and the generated PHP class code will be displayed in the output area, including PHP opening and closing tags.
Related Tools
JSON Formatter & Validator
Format, beautify, minify, and validate JSON data instantly in your browser with syntax highlighting and tree view.
CSV to JSON Converter
Convert CSV and TSV spreadsheets to structured JSON instantly. Auto-detect delimiters, support custom headers, and preview before conversion.
YAML to JSON Converter
Convert YAML configuration files to JSON format instantly with validation and syntax error reporting for both formats.