Paste a JSON sample and get clean Dart classes with fromJson and toJson methods — nested objects become their own classes, arrays become List types, and nullable fields are inferred. Fast, secure, and entirely in your browser.
No installation, no signup. Results in milliseconds.
A JSON to Dart converter reads a sample of JSON and writes the Dart classes that describe its shape, each with a fromJson factory and a toJson method. Instead of hand-writing a model and its serialization for every API response, you paste the response and get ready-to-use classes for your Flutter or Dart app.
Dart has no reflection-based JSON binding, so every model needs explicit fromJson and toJson code. Writing that by hand for a large payload is tedious and easy to get wrong. Generating it from a real sample means the types, the null-safety, and the serialization all match the data.
List<String>, List<Item>).int vs double, and nullable (Type?) fields.fromJson factory and a toJson method on every class.These are the inference rules the converter applies so the output is predictable.
| JSON | Becomes in Dart |
|---|---|
Object { } | A class with a fromJson factory and a toJson method. |
| Nested object | Its own named class, referenced from the parent field. |
Array [ ] | A List<T> such as List<String> or List<Item>. |
| Whole number | int. |
| Decimal number | double. |
| string / boolean | String / bool. |
| Missing key / null | A nullable type, such as int?. |
| null only / mixed types | dynamic (or List<dynamic> for a mixed array). |
Every class gets a fromJson factory that reads each key from a Map<String, dynamic> with the right cast, and a toJson method that writes the map back. Non-nullable fields are required in the constructor; a field becomes nullable (Type?) when its key is missing from some records or its value is sometimes null. Validate the JSON first with the JSON parser if it will not convert, or tidy it in the JSON formatter.
dynamicA field that is only ever null, an empty array, or holds more than one unrelated type has no single Dart type, so it falls back to dynamic. Paste a representative sample with those fields populated to get precise types, and give an array of several records so every key is seen. For a deeply nested payload, expanding it in the JSON viewer first helps you confirm the shape.
See how a nested object with an array of items becomes clean Dart classes with serialization.
Notice three things: items became its own Item class decoded with a .map() call, total is a double because the sample has a decimal, and each class carries both fromJson and toJson. For the step-by-step reasoning, see our guide on converting JSON to Dart classes.
Typed, serializable models from real data, in seconds.
Everything developers ask about generating Dart classes from JSON.
fromJson factory constructor that builds it from a Map<String, dynamic>, and a toJson method that returns one, because Dart has no built-in reflection-based JSON binding and expects these methods.int and numbers with a decimal point become double. Dart distinguishes the two, so a representative sample makes sure a field that can hold decimals is typed double.Type?) when its key is missing from some objects in an array or its value is sometimes null, and its constructor parameter drops the required keyword. Non-nullable fields are marked required.List<String> or List<Item>, decoded with a map call.dynamic (or List<dynamic> for a mixed array).Root.fromJson(jsonDecode(source) as Map<String, dynamic>), and encode back with jsonEncode(value.toJson()). No build_runner or code generation step is required.Hands-on articles from our blog.
All free, all browser-based, no signup required.