JSON to Dart class
Turn a JSON sample into a Dart class with fromJson, toJson and nested models.
JSON to Dart class
Paste a JSON sample and this tool infers the shape of the data and generates a matching Dart class — the kind you would otherwise hand-write for a Flutter model. Nested objects become their own classes, arrays become typed `List<...>` fields, and every class ships with a named constructor, a `fromJson` factory and a `toJson` method, so the result drops straight into a Flutter or Dart project.
The options control the style of the generated code. "Class name" sets the root class; nested classes are named after the JSON key that introduced them. "Null safety with required fields" marks fields that are present in every sample as `required` with a non-nullable type, and fields that are sometimes missing or null as nullable and optional; turn it off to make every field nullable instead. "json_serializable annotations" swaps the hand-written `fromJson`/`toJson` bodies for `@JsonSerializable()` and `@JsonKey`, which delegate to a generated `.g.dart` part file. "Final fields" makes the class immutable; "Generate copyWith" adds a method for creating a modified copy without mutating the original, and "Generate == and hashCode" adds value equality so two instances with the same field values compare equal. "Indent" switches between 2- and 4-space indentation.
When the same object shape repeats — an array of items that all have the same fields, for example — the tool reuses one class instead of generating a duplicate for each occurrence, and a field only missing from some entries in an array is correctly inferred as optional rather than required. JSON keys that aren't valid Dart identifiers, use different casing, or collide with a keyword or a generated method name (like `copyWith` or `hashCode`) are automatically renamed on the Dart side while the original key is preserved for encoding and decoding.
Everything runs locally in your browser: no JSON sample is ever uploaded, which matters if it holds real user data or an internal API's response shape. Copy the class, download it as a .txt file, or send the output back into the input to convert one nested piece further.