JSON to Dart Converter
Free online JSON to Dart converter. Paste an API sample and instantly generate typed data classes with fromJson and toJson factories, null safety and final fields, ready for Flutter. Everything runs locally in your browser.
What does the JSON to Dart converter generate?
It generates ready-to-use Dart classes with typed fields plus fromJson and toJson factories for every model, so you can decode and encode API payloads with plain Dart — no build_runner step or extra package required.
How are nested objects handled?
Every JSON object becomes its own class. The parent keeps a field of the nested type, its fromJson calls the child class factory recursively, and toJson calls the child's toJson, so deep payloads map to a small class tree.
What happens with arrays of objects?
Objects from different array elements are merged: the union of all their keys becomes one element class, and the field is typed List<ElementClass>. Keys missing from some elements are automatically marked nullable.
What does the null safety option change?
With null safety on, fields that can be absent or null get a ? suffix, the constructor makes them optional named parameters, and fromJson reads them with null-aware casts. Turn it off to emit plain non-nullable style types.
When should I enable the final option?
final declares every field as immutable after construction, which is the recommended style for Dart data classes and lets the analyzer catch accidental mutations in your models.
What happens if a JSON key is not a valid Dart identifier?
Keys like @type or order-id are automatically renamed to a legal camelCase identifier (with a $ prefix when the key starts with a digit). The generated fromJson still reads the original key string, and a notice lists every renamed field.
How are class names chosen?
The top-level class takes the name you type in the Class name box, converted to PascalCase. Nested classes derive their PascalCase name from the JSON key that produced them, so a user_profile key becomes a UserProfile class.
Is my JSON sent to a server?
No. Parsing and code generation run entirely in your browser and the .dart file is created locally for download, so private API samples and tokens never leave your machine.
How to Use JSON to Dart Converter
Turn a JSON sample into ready-to-use Dart data classes without leaving the browser. Classes, factories and casts are generated locally — your payload is never uploaded.
- Paste your JSON into the left editor; the Dart code appears on the right as you type (300 ms debounce).
- Set the top-level name in "Class name:" — it is converted to PascalCase for the root class.
- Toggle "Null safety" to add ? to nullable fields and emit null-aware casts in fromJson.
- Toggle "final" to declare every field immutable, then Copy the result or Download it as a .dart file.
Nested objects become their own classes, arrays of objects merge into one element class typed List<Element>, and invalid keys like @type are renamed automatically while fromJson keeps reading the original key.
Related Tools
- JSON to TypeScript Instantly convert JSON to TypeScript interfaces and type definitions. Supports nested objects, arrays, and union types.
- JSON to Go Struct Convert JSON to Go struct definitions instantly. Paste JSON and get clean Go code with proper types, json tags, and omitempty support.
- File Hash Checker Calculate and verify MD5, SHA-1, SHA-256, SHA-512 file hashes locally
- Chmod Calculator Free online chmod calculator to visualize and calculate Linux file permissions with checkboxes. Instantly convert between numeric (755, 644) and symbolic notation (rwxr-xr-x). Supports special permissions like setuid, setgid, sticky bit.
- ASCII Table Complete ASCII character encoding reference with decimal, hexadecimal, octal, binary codes, HTML entities, and character descriptions. Search and filter instantly.
- Hex Viewer View file contents in hex dump format with search, offset navigation, and virtual scrolling
- MIME Type Lookup Instantly find MIME types by file extension or look up extensions by MIME type. Free online reference with 1000+ entries.
- Screen Resolution Checker Detect screen resolution, viewport size, DPI, color depth and display info in real time.