Skip to main content

JSON to PHP

New

Generate PHP 8+ typed classes with fromArray hydration from JSON data.

convertphpclass
Read the guide
Shortcuts:⌘ KSearch
Produces PHP 8+ typed classes with recursive fromArray hydration.

Frequently Asked Questions

What exactly does this generator output for PHP?

It produces PHP 8+ classes with typed public properties and a static fromArray(array $data): self hydrator.

Does it generate constructors or toArray methods?

No. The output is centered on property declarations plus recursive fromArray hydration, not full DTO boilerplate.

How are nested arrays of objects hydrated?

Arrays of objects are mapped with array_map, and each item is passed through the nested class's fromArray method.

Why are there docblocks above array properties?

PHP property types can say array, but not the element type. The generator adds @var Foo[]-style docblocks so the item type is still visible to IDEs and static analysis.

What happens with top-level arrays or null values?

A root array becomes a class with an items property. Null values fall back to nullable mixed.

Related Tools