JSON to Dart Class Converter
Convert JSON objects into strongly-typed Dart Class definitions and data models.
To convert JSON to Dart Class, paste your JSON payload above and specify the root type name. The generator creates clean, idiomatic Dart Class code definitions instantly in your browser without uploading your JSON data to external servers.
Runs in your browser- Privacy
- Runs entirely in your browser — nothing is uploaded
- Cost
- Free, unlimited, no sign-up
From a JSON sample to a Dart class
The output is a class of final fields with a constructor whose parameters are all required named arguments. That shape is deliberate: it is what sound null safety pushes you toward, and it is the shape json_serializable and freezed expect to decorate. What it does not write is fromJson and toJson, because how you decode is a project decision rather than something a sample payload can answer.
What one sample can and cannot tell it
- Nullability is inferred, not known. Dart has been non-nullable by default since 2.12, so every field arrives non-nullable. Anything the server may omit or send as
nullneeds a?adding by hand. - A JSON
nullcarries no type information at all, so it becomesdynamic. That is the honest reading of the sample and almost never the type you want to ship. - A nested object becomes its own class named after its key, and the parent holds a reference to it rather than an inline map.
- A list is typed from its first element.
List<String>from a list of strings is right; a list mixing objects and nulls needsList<dynamic>or a hand-written union. - Integer and double are told apart by whether the sample value had a fractional part. A price that happened to be
10infersintand will throw the first time the API sends10.5. Widen it todoubleornum.
Building the same model on the other side of a cross-platform app? JSON to Kotlin and JSON to Swift take the same payload, and JSON to TypeScript covers the web client.
Frequently asked questions
Does this JSON to Dart Class converter upload my files?
How to use the json to dart class converter
- 1Enter or paste your json.
- 2Enter or paste your root type name.
- 3Press Run, then download the result when it is ready.
Sources & specifications
Embed this tool
Put the working json to dart class converter on your own site. It runs in your visitors' browsers exactly as it does here — free, no account, nothing uploaded.
Share this tool
Related tools
Last updated
More data & format tools