JSON to Dart Converter
Paste a JSON object and get Dart classes for Flutter or Dart projects — including `fromJson` factory constructors and `toJson` methods.
Last updated: May 27, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is JSON to Dart Converter?
Flutter and Dart developers typically write a model class per JSON response, with a `fromJson` factory constructor for deserialization and a `toJson` method for serialization. Writing both directions by hand is mechanical work that scales poorly with the number of endpoints.
This tool generates the full pattern: field declarations with inferred types, a constructor with named parameters, a `fromJson(Map<String, dynamic>)` factory, and a `toJson()` method that mirrors the field names back to a map. Nested objects produce their own classes with their own conversion methods, so deeply nested API responses come out fully typed.
How to Use JSON to Dart Converter
Paste a JSON object (root must be an object).
Set the root class name.
Toggle final fields, nullable types, and fromJson/toJson generation.
Copy the generated classes into your project.
Common Use Cases
- Generating Flutter model classes from REST API responses.
- Bootstrapping data classes for json_serializable migration.
- Quick scaffolding for a Dart CLI that consumes JSON.
- Producing a starting point that you refine with package:freezed or similar.
Example Input and Output
A flat JSON object generates a Dart class with fromJson and toJson.
{ "userId": 42, "name": "Alice", "active": true }class Root {
final int? userId;
final String? name;
final bool? active;
Root({this.userId, this.name, this.active});
factory Root.fromJson(...) { ... }
Map<String, dynamic> toJson() { ... }
}Privacy
All conversion happens in your browser. No JSON is sent to a server.
Lists of primitives
List<int>, List<String>, etc. use .cast<T>() in fromJson to safely convert from List<dynamic>. List<NestedClass> uses .map((e) => NestedClass.fromJson(e)).toList().
Frequently Asked Questions
Why are fields nullable by default?
JSON values can be missing, and Dart sound null safety requires explicit nullability. Disabling "Nullable" produces non-nullable fields with required constructor parameters — useful when you trust the API to always return every key.
fromJson / toJson or freezed / json_serializable?
This tool produces hand-written conversion code. For complex projects, consider freezed + json_serializable for code generation and value equality. The classes here are a good starting point to migrate from.
How are int vs double distinguished?
Number.isInteger checks the input value: a whole number becomes int, a decimal becomes double. If you need explicit num to accept both, change manually.
Does this send my JSON anywhere?
No. All generation happens locally in your browser.
Related Tools
JSON to Java Converter
Generate Java POJO classes from a JSON example. Infers types, creates nested classes, handles arrays as List<T>, and optionally uses Lombok @Data or full getters/setters.
JSON to TypeScript Interface
Convert any JSON object into TypeScript interfaces instantly — handles nested objects, arrays, union types, optional fields, and generics.
JSON to C# Converter
Generate C# classes from a JSON example. Infers types, creates nested classes, handles arrays as List<T>, and optionally emits [JsonPropertyName] attributes for System.Text.Json.
JSON to Go Struct Converter
Generate Go structs from a JSON example. Infers types, creates nested structs, handles arrays as slices, and emits json:"..." struct tags ready for encoding/json.
JSON to Python Converter
Generate Python classes from a JSON example. Choose @dataclass, pydantic BaseModel, TypedDict, or attrs style. Targets Python 3.10+ or 3.9 type syntax.
JSON to Proto Converter
Generate a Protocol Buffers (proto3) schema from an example JSON object. Infers field types, creates nested messages, and handles arrays as repeated fields.

