How to use the JSON to Dart
- Paste a JSON object or array (for example an API response) into the input box.
- Set the root class name and pick options such as nullable fields or copyWith.
- Copy the generated Dart code or download it as a .dart file and add it to your Flutter project.
Features
- Null-safe Dart 3 output with final fields
- Nested objects become their own classes; arrays become typed List<T>
- fromJson / toJson factories and optional copyWith
- Choose nullable or required fields and the root class name
- Runs 100% in the browser — your JSON is never uploaded
Frequently asked questions
Does the generated code work with null safety?
Yes. Output targets Dart 3 with sound null safety. Choose 'nullable fields' to make every field optional (Type?) when your API may omit keys, or leave it off to generate required fields.
How are nested objects and lists handled?
Every nested JSON object becomes its own Dart class named after its key (e.g. "address" → Address). Arrays of objects become List<ClassName> and arrays of primitives become List<int>, List<String>, etc.
Should I use this or json_serializable?
For small and medium models, hand-written fromJson/toJson (what this tool generates) has zero build_runner overhead. For very large codebases json_serializable or freezed can be easier to maintain — this tool is a fast way to start either way.