JSON to Dart Converter
Generate null-safe Dart classes and JSON mapping functions, including nested objects, lists and nullable properties.
How to generate Dart models
Start with a root class such as Profile. Copy the selected .dart file or download the ZIP when the result is split across files. Check generated mappings for JSON keys such as display-name.
Complete output uses dart:convert and generated fromJson/toJson mappings; no code generation build step is needed. Models-only mode omits conversion functions. Dart compiled to JavaScript cannot exactly represent every signed 64-bit integer: use string IDs for values beyond the web runtime’s safe integer range.
Samples, optional fields and limits
Keep strings as strings when preparing Dart samples, even for IDs, dates and UUIDs. Treat the result as a model inferred from examples. Limits are 200,000 input characters, 64 nesting levels, 50 samples, 50 files and 1,000,000 output characters. The local worker can be cancelled and has a 10-second deadline.
Questions & answers
How should I sample missing and null fields for Dart?
Include several payloads in JSON Lines if a field appears only on some responses. Inspect its inferred Dart type, especially for null values and empty lists, and include a non-empty list sample when possible.
Does Dart model generation call an API?
The page reads the JSON samples locally and returns Dart source. It does not fetch a schema or run fromJson/toJson on a server.
Other Languages
References
How we make sure
We check this tool with the automated test suites linked below. Example checks are shown in their original language.
- Verification method
- Check generated Dart null-safe classes and fromJson/toJson name mappings against fixed JSON fixtures.
- Comparison reference
- Explicit declaration/field-mapping assertions and generator integration.
- Verification scope
- These cases are not all claimed to invoke the target-language compiler.
Test source and cases (select a file to read it)
-
code-tools.test.js
- JSON to Dart creates null-safe classes and original-key fromJson/toJson mappings
These checks cover the listed examples and boundaries, not every possible input. Round trips and checks using the same library are not independent verification.