JSON to Dart Converter

Convert JSON to Dart
classes online, free & instant

Paste your JSON and generate null-safe Dart model classes with fromJson/toJson methods. Perfect for Flutter apps. Runs entirely in your browser — no upload, no account, no waiting.

Open JSON to Dart Converter

From JSON to Flutter-ready Dart in seconds

Paste your API response Drop any JSON object into the input. Each key-value pair is analyzed to infer the correct Dart type with null safety.
Null-safe type inference Strings become String, numbers become int or double, booleans become bool, and arrays become List<T> — all with sound null safety.
fromJson & toJson methods Generated classes include factory fromJson constructors and toJson methods, ready for JSON serialization in Flutter.
Copy into your Flutter project One-click copy sends the Dart code to your clipboard. Drop it into your models folder and start using it immediately.

No account. No upload. No nonsense.

🔒

100% Private

Your JSON never leaves your device. There is no server receiving your data.

Instant Output

Conversion happens as you type. No round-trips to a backend, no latency.

🎯

Flutter-Ready

Generated models work with http, Dio, Retrofit, and any Flutter JSON workflow out of the box.

Related JSON tools

JSON to Java Generate strongly-typed Java POJO classes from JSON with nested class support.
JSON to Zod Generate Zod validation schemas from JSON for TypeScript runtime safety.
JSON Validator Validate JSON syntax and get clear, pinpointed error messages.
JSON Formatter Pretty-print JSON with syntax highlighting and a collapsible tree view.

Common questions answered

Is the JSON to Dart converter free?

Yes, completely free with no account or signup required. The converter runs entirely in your browser.

Does the converter support Dart null safety?

Yes. The generated Dart classes use sound null safety with proper nullable type annotations. Fields that could be null are marked with the ? suffix, making the code compatible with Dart 3 and Flutter's latest versions.

Can I use the generated Dart classes in Flutter?

Absolutely. The generated classes include fromJson factory constructors and toJson methods, making them ready to use with Flutter's http package, Dio, Chopper, or any JSON-based API client.

How does the converter handle nested JSON objects in Dart?

Each nested JSON object generates a separate Dart class with its own typed fields, fromJson constructor, and toJson method. The parent class references the nested class by type, preserving the full structure.

Is my data sent to a server during conversion?

No. All conversion runs entirely in your browser using JavaScript. Your JSON is never uploaded or transmitted to any server.

Converting JSON to Dart classes

Dart classes are the standard way to handle JSON in Flutter applications. Unlike JavaScript, Dart requires explicit typed fields. This tool generates Dart class definitions including a fromJson factory constructor for deserialization and a toJson method for encoding, working directly with dart:convert.

The converter follows Dart conventions: PascalCase class names, camelCase fields, List<T> for arrays, and nullable types (String?) for optional fields. Each class includes fromJson/toJson methods with proper null-safety annotations. The output is compatible with manual parsing and code-generation tools like json_serializable.

Convert JSON to Dart classes
Input
{
  "name": "Alice",
  "age": 30,
  "roles": ["admin"],
  "bio": null
}
Output
class Root {
  final String name;
  final int age;
  final List<String> roles;
  final String? bio;

  Root({required this.name,
    required this.age,
    required this.roles, this.bio});

  factory Root.fromJson(
    Map<String, dynamic> json) =>
    Root(
      name: json['name'],
      age: json['age'],
      roles: List<String>.from(
        json['roles']),
      bio: json['bio'],
    );
}

Get the most out of this tool

Ready to convert your JSON to Dart?

Free forever. No signup. Works offline.

Convert JSON to Dart now

Dart model classes for Flutter JSON

Dart is the language behind Flutter, Google's cross-platform UI framework. When Flutter apps communicate with REST APIs, they receive JSON responses that must be parsed and mapped to Dart objects. Dart's dart:convert library provides jsonDecode() which returns dynamic — a type that carries no compile-time type information. To get type-safe access to JSON data, you need Dart model classes with fromJson() constructors. This converter generates those classes automatically from your JSON input.

The converter generates Dart classes with standard conventions: fields use camelCase, class names use PascalCase, and each class includes a fromJson(Map<String, dynamic> json) factory constructor and a toJson() Map<String, dynamic> method. These two methods are the standard interface for JSON serialization in Dart without code generation. The factory constructor pattern is preferred over a regular constructor because it allows returning different instances or handling errors during construction.

JSON type mapping in Dart follows straightforward rules. JSON strings become String. JSON integers become int. JSON floating-point numbers become double. JSON booleans become bool. JSON null maps to nullable types in Dart's null-safe type system (String?, int?, etc.). JSON arrays become List<T>. Nested JSON objects become nested Dart class instances, with the fromJson constructor calling the nested class's fromJson recursively.

Dart's null safety, introduced in Dart 2.12 and required in Flutter 2.0+, means every type is non-nullable by default. A field of type String cannot be null — if you try to assign null to it, Dart throws a compile-time error. When a JSON field might be absent or null in the response, the Dart field must be declared as String? (nullable). The converter handles this by marking fields nullable when their JSON values are null in the provided sample — review the output based on your API's documented contract.

The json_serializable package (with build_runner) offers an alternative to hand-written fromJson/toJson methods. With @JsonSerializable() annotations and running flutter pub run build_runner build, the boilerplate is generated from annotated class fields. The downside is the added build step and dependency. For simple models with a few fields, hand-written fromJson/toJson as generated by this tool are often simpler and more transparent.

For Flutter apps using state management with Riverpod, BLoC, or Provider, Dart model classes are the natural data layer. Immutable model classes — declared with final fields and no setters — work well with these patterns. The copyWith() method, which returns a new instance with some fields changed, is commonly generated alongside fromJson/toJson. Freezed is a popular code generation package that produces immutable models with copyWith, equality, and JSON support in one step.

When developers use this tool

Flutter REST API integration Generate Dart model classes from a REST API's JSON response to use with the http or dio package. The generated fromJson constructor maps the response body directly to your typed Dart objects.
Firebase Firestore data modeling When reading Firestore documents in Flutter, convert your expected document JSON structure to a Dart class with fromJson/toJson. Use it with documentSnapshot.data() for type-safe Firestore data access.
Local storage and shared preferences When serializing complex objects to JSON for local storage in Flutter (using shared_preferences or Hive), generate the toJson/fromJson methods to handle the serialization round-trip cleanly.
Dart server-side (shelf/Dart Frog) Dart server-side frameworks like shelf and Dart Frog handle JSON request and response bodies. Generate Dart classes from your API contract to use in request handlers for type-safe request parsing.

Additional frequently asked questions

Should I use json_serializable or write fromJson manually?

For large projects with many model classes that change frequently, json_serializable with build_runner reduces maintenance burden — you only update the field declarations, not the serialization code. For small projects or classes that rarely change, manually written fromJson/toJson as generated by this tool avoids the build step and keeps the code transparent and explicit.

How do I handle nullable JSON fields in Dart null safety?

Declare the field as nullable (String? instead of String) and use the null-aware access in fromJson: json['field'] as String?. For the toJson method, null fields are simply included as null in the map, which jsonEncode handles by outputting JSON null. Use json['field'] ?? defaultValue for fields with default values instead of null.

What is the Freezed package and should I use it?

Freezed is a code generation package for Dart that generates immutable model classes with copyWith(), equality, and JSON serialization in one step. It is more powerful than manual fromJson/toJson but requires build_runner. For Flutter apps with complex state management requirements (especially with Riverpod), Freezed is highly recommended. For simple API models, manual generation is sufficient.

Can I use the generated Dart classes with GraphQL?

Yes, with adaptation. GraphQL responses also return JSON, so the generated fromJson constructors work for GraphQL response data. However, GraphQL clients like graphql_flutter typically generate their own typed models from the GraphQL schema using code generation. For REST-to-GraphQL migrations or hybrid APIs, the manual approach works as a bridge.