JSON to PHP Class Converter
Convert JSON to PHP 7.4+ classes with typed properties. Generates one class per nested object, phpdoc @var array<T> for typed arrays, and camelCase property names. 100% local.
Last updated:
CommentsPaste JSON to generate PHP 7.4+ classes with typed properties, camelCase names, and phpdoc @var array<T> for typed arrays. One class per nested object. 100% local.
Tips & Best Practices
- ▸PHP 7.4+ is required for typed properties. For older PHP, remove the type declarations manually.
- ▸PHP has no generic array types — the phpdoc comment is what static analyzers (PHPStan, Psalm) and modern IDEs use for autocomplete.
- ▸Great starting point for Laravel Eloquent models — add table / column annotations after generation.
Frequently Asked Questions
What PHP version is required?
The output uses typed properties, which are available in PHP 7.4 and later. For PHP 7.3 and earlier, remove the type declarations manually — the property names and phpdoc comments still apply.
How are arrays typed?
PHP has no generic array types, so array is used as the declared type and a phpdoc /** @var T[] */ comment is added above the property. Static analyzers (PHPStan, Psalm) and IDEs pick this up for autocomplete.
Can I paste this into Laravel Eloquent or Doctrine?
Yes — it's a starting point. Add table / column annotations and rename the class as needed. The property names and types are the tedious part; this tool handles that.
Is my JSON uploaded anywhere?
No. All conversion happens in your browser.
Try Next
JSON → Python
Convert JSON to Python @dataclass definitions with typed fields. snake_case field names, nested classes, List[T] for arrays, and JSON-key alias comments. 100% local.
Related Tools
Number Base
Convert numbers between binary, octal, decimal, and hexadecimal. Supports arbitrarily large integers using BigInt.
JSON → TypeScript
Convert JSON to TypeScript interfaces instantly. Generate strongly-typed TS types from any JSON sample.
JSON → Go
Convert JSON to Go structs online. Generates idiomatic Go structs with proper json tags and PascalCase field names.
JSON → YAML
Convert JSON to YAML online. Preserve structure, comments-free, and ready to paste into Kubernetes or CI configs.
YAML → JSON
Convert YAML documents to JSON online. Supports YAML 1.2, multi-document streams, and produces pretty-printed JSON output.
JSON → CSV
Convert an array of JSON objects to CSV online. Headers are inferred automatically from all keys across records.