JSON to Eloquent Model & FormRequest.
Generate a Laravel Eloquent model, casts and FormRequest validation rules from a sample JSON payload.
Runs in your browserAbout JSON to Eloquent Model & FormRequest
This generator turns a sample JSON payload, such as an API request body or a record exported from another system, into the Laravel code you would otherwise write by hand: an Eloquent model and a FormRequest with validation rules. It inspects every key and infers a type from the value. Integers, floats and booleans get matching casts and the integer, numeric and boolean rules; ISO 8601 strings become datetime or date casts with the date rule; strings that look like an email address, URL or UUID get the email, url or uuid rule; and arrays and nested objects become array casts with dot-notation rules such as tags.* and meta.views. Keys ending in _id produce a belongsTo() relation and an exists rule, so userId becomes user_id with exists:users,id. With snake_case conversion on, camelCase keys are renamed the way Laravel attributes usually look. Paste an array of objects to merge several samples: a key that is missing from some records gets the sometimes rule, and a key that is null in any record becomes nullable. id, created_at, updated_at and deleted_at are left out of $fillable and the rules, and deleted_at adds the SoftDeletes trait. A typical mistake with generated rules is trusting max:255 for every string; check long text fields and adjust the limits, and add unique or enum rules the sample cannot reveal. The JSON is processed in your browser and never uploaded.
How to Use
- Paste one JSON object, or an array of objects to merge several samples.
- Enter the model name and choose whether to convert camelCase keys to snake_case.
- Copy the model into app/Models and the FormRequest into app/Http/Requests, then review the rules.
Frequently Asked Questions
How are nullable and required decided?
A key with a non-null value in every sample is required. A key that is null in any sample is nullable, and a key that is missing from some samples gets sometimes.
Does it create relations?
Integer keys ending in _id get a belongsTo() method and an exists rule that points at the plural table, for example author_id → Author and exists:authors,id. Has-many relations cannot be inferred from one record.
Why are some strings max:255 and others not?
Strings up to 255 characters in the sample get max:255, matching a VARCHAR(255) column. Longer samples are treated as text without a limit. Adjust the limits to your schema.
Is my JSON uploaded?
No. Type inference and code generation run in your browser.
Related Tools
Turn CREATE TABLE statements from MySQL, PostgreSQL or SQLite into a Laravel migration.
Convert a SELECT statement into Laravel Query Builder and Eloquent code.
Generate typed code from JSON data.
Pretty print, minify, and validate JSON.
Wrap a JSON Schema as a function/tool definition for OpenAI, Anthropic and MCP, with optional strict mode.
Check which versions a Composer constraint like ^8.2 || ~7.4.0 accepts, with stability flags.