WebToolsPlanet
Converter Tools

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

Client-Side Processing
Input Data Stays on Device
Instant Local Execution

Find this tool useful? Support the project to keep it free!

Buy me a coffee

What 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

1

Paste a JSON object (root must be an object).

2

Set the root class name.

3

Toggle final fields, nullable types, and fromJson/toJson generation.

4

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.

JSON input
{ "userId": 42, "name": "Alice", "active": true }
Generated Dart class
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.