Flutter 3.50 is live! Read the blog post
Tools/JSON to Dart

JSON to Dart Converter

Convert JSON to Dart model classes instantly. Generates fromJson, toJson, copyWith — supports null safety, Equatable, json_serializable & Freezed.

JSON Input
Dart Output

Paste JSON and click Convert

Instant conversion

Handles nested objects, arrays, null values, and multiple classes in one click.

Null-safe output

Generated code is fully compatible with Dart's sound null safety introduced in Dart 2.12.

Multiple patterns

Plain Dart, json_serializable for codegen, or Freezed for immutable value types.

Related Tools

// more about this tool

Why convert JSON to Dart by hand

Every Flutter app that talks to an API ends up writing the same boilerplate: a class per response shape, a fromJson factory that reads each key, a toJson that writes it back, and usually a copyWith for state updates. Doing this by hand for a payload with fifteen fields is slow and it's exactly the kind of work where a typo in a key name fails silently at runtime instead of at compile time, usually as a null-check crash several screens away from where the mistake was made.

This tool parses the JSON you paste in, infers a Dart type for each field (String, int, double, bool, nested objects, and typed lists), and generates a null-safe class with fromJson, toJson, and copyWith already written. If a value is a nested object, it generates a class for that too, so a response with an address or a list of posts comes out as fully-typed nested models, not a pile of dynamic maps.

How it works

  1. Paste a sample JSON response into the input panel — ideally one with every field populated, not a partial example.
  2. Set the root class name and, optionally, a suffix like Model, Dto, or Entity.
  3. Pick an output style: plain Dart, json_serializable, or Freezed.
  4. Toggle null safety, copyWith, and Equatable to match your project's conventions.
  5. Click Convert, then copy the generated classes straight into your project.

Example

Input

{
  "id": 1,
  "name": "Bilal Fali",
  "is_active": true
}

Generated Dart (plain output)

class UserModel {
  final int id;
  final String name;
  final bool isActive;

  const UserModel({
    required this.id,
    required this.name,
    required this.isActive,
  });

  factory UserModel.fromJson(Map<String, dynamic> json) {
    return UserModel(
      id: json['id'] as int,
      name: json['name'] as String,
      isActive: json['is_active'] as bool,
    );
  }
}

FAQ

Does my JSON leave the browser?

No. Parsing, type inference, and code generation all run client-side in JavaScript. Nothing you paste in is sent to a server or logged anywhere.

What happens if a field is null in my sample?

The tool has no way to know a null field's real type, so it falls back to dynamic for that field. Paste a sample where every field actually has a value to get a precise type, then double-check the generated field against your API's real schema.

Should I pick Freezed, json_serializable, or plain Dart?

Match whatever your project already uses for models. Plain Dart has zero dependencies and is fine for a small app or a quick prototype; json_serializable and Freezed both rely on build_runner codegen, so mixing their generated classes with hand-written ones in the same project tends to cause confusion rather than save time. Freezed additionally gives you union types and pattern matching if your models need that.

Does it handle nested objects and lists of objects?

Yes — a nested object becomes its own generated class named after its key, and a list of objects becomes a typed List<T> of that class rather than List<dynamic>, so you get full type safety even through several levels of nesting.

What's the difference between this and the Dart Data Class Generator?

This tool generates fromJson/toJson for API serialization; the Dart Data Class Generator produces an immutable value class with copyWith and equality but no serialization. Use this one whenever the data is coming from or going to JSON.