JSON to PHP Converter
Paste JSON and generate PHP output for common backend workflows: native arrays, typed classes, Laravel-style DTOs, or a conservative Eloquent model starter.
JSON to PHP Array
PHP Array mode keeps the actual JSON values and converts objects into associative arrays. Strings are escaped for single-quoted PHP strings, booleans become true or false, and JSON null becomes PHP null.
JSON to PHP Class
PHP Class mode infers public properties from the JSON shape. You can enable typed properties and choose whether to generate a constructor with promoted properties.
JSON to Laravel DTO
Laravel DTO mode creates native final PHP classes with constructor promoted properties. It does not require Spatie Data, Laravel Data, or any other package, which makes the output easy to adapt to your own conventions.
JSON to Laravel Model
Laravel Model mode generates an Eloquent model starting point with $fillable and useful $casts. Nested objects and arrays are treated conservatively as JSON columns unless you decide to model relationships explicitly.
Handling nested JSON
Nested objects become nested PHP classes in class and DTO modes. Arrays of objects generate array properties with PHPDoc hints so the generated code stays readable while remaining native PHP.
PHP type mapping
Strings map to string, booleans to bool, numbers to int or float when the sample makes that clear, arrays to array, and null can make typed properties nullable.
Privacy
This JSON to PHP converter runs in browser memory. It does not make an Ajax request, store your JSON in localStorage, or write your input to Laravel logs, sessions, cookies or a database.
FAQ
Does this JSON to PHP converter upload my JSON?
No. It runs locally in your browser and does not send JSON to the server.
Can it generate PHP arrays?
Yes. PHP Array mode outputs native short array syntax.
Can it generate Laravel DTOs?
Yes. It generates native final classes with constructor promoted properties.
Can it generate Eloquent models?
Yes. It creates a starting model with fillable fields and casts, while treating nested JSON conservatively.