JSON to Dart

Paste JSON and instantly get matching Dart model classes with fromJson/toJson factories and nullable-safe fields.

Use the JSON to Dart

Input JSON

Dart Output

Paste JSON and click Generate

Copied!

Summary

JSON to Dart reads a JSON value and generates matching Dart model classes, including separate classes for nested objects and List types for arrays. Every class comes with a fromJson factory constructor and a toJson method, matching the pattern used across Flutter apps. When a field is missing from some entries in an array of objects, or the field can hold a null value, the generated property is typed nullable so the class stays safe to construct from partial data. Field names are converted to camelCase and the original JSON key is noted in a comment whenever it differs from the Dart property name.

How it works

  1. Paste or type JSON into the input panel, or load a sample.
  2. Set a root class name (defaults to RootObject).
  3. Click Generate to parse the JSON and build Dart model classes.
  4. Nested objects become their own named classes; arrays of objects are scanned across all items to detect optional fields.
  5. Fields that are missing from some items, or that hold null, become nullable properties.
  6. Click Copy to copy the Dart code to your clipboard.

Use cases

  • Scaffold model classes for a REST API response before wiring up an http or dio call in Flutter.
  • Turn a sample config file into a typed Dart settings class.
  • Generate a starting model with fromJson/toJson without typing every field by hand.
  • Document a third-party API response shape as Dart types.
  • Check which fields are optional before writing null-handling logic by hand.
  • Speed up adding a new Flutter model from sample JSON during prototyping.

Frequently Asked Questions

Last updated: 2026-07-13 · Reviewed by Nham Vu