Free JSON to Dart — Flutter model classes

Convert JSON to Dart
fromJson, toJson,
null safety, copyWith.

Free JSON to Dart converter for Flutter. Generates model classes with fromJson, toJson, null safety and copyWith. Nested objects become separate classes. Runs entirely in your browser — no upload, no account.

Your data never leaves your browser
Dart null safety support
Nested objects → separate classes
copyWith for immutable models
Always free
JSON to Dart Converter   100% client-side
Dart class generation uses vanilla JavaScript — no external library, no data upload.
JSON input
  Dart class ready

      
How to convert JSON to Dart

Three steps — paste your JSON and drop the class into your Flutter project.

1
Paste your JSON response

Paste a sample JSON response from your API — a single object or an array. The converter uses the structure and values to infer Dart types: int, double, String, bool, List and nested classes. Use a real response with non-null values for the most accurate type inference.

2
Set class name and options

Enter the root class name (e.g. User, Product, ApiResponse). Toggle null safety for Dart ≥ 2.12 projects, include toJson for serialisation, and add copyWith if you use immutable state management with Provider, Riverpod or Bloc.

3
Copy and use in Flutter

Click Generate and copy the Dart code directly into your project — or download as a .dart file. The class is ready to use: paste it into your models folder, import it, and call ClassName.fromJson(response.data) immediately.

How JSON to Dart type inference works

How the converter maps JSON value types to Dart types.

Dart is a strongly-typed language — every field in a model class needs an explicit type. JSONshift infers Dart types from the JSON values in your sample: JSON integers become int, floating-point numbers become double, strings become String, booleans become bool, and nested objects become a new Dart class with a PascalCase name derived from the key.

Null safety (introduced in Dart 2.12) changes how optional fields are handled. A field whose sample value is null in the JSON becomes a nullable type like String? — it can safely be absent from the API response. Fields with non-null values are typed without the ? and are treated as required. This maps directly to how Dart's type system distinguishes between must be present and may be absent.

The fromJson factory constructor uses json['key'] as Type for primitives and NestedClass.fromJson(json['key']) for nested objects. The toJson method returns a Map<String, dynamic> with nested objects serialised via their own toJson() — making the class compatible with json_serializable conventions and directly usable with dio, http and Dart's jsonEncode.

When do you need JSON to Dart models?

Common Flutter development workflows where model generation saves time.

REST API integration

Every Flutter app that fetches data from a REST API needs model classes to deserialise the JSON response. Generating fromJson from the actual API response — rather than writing the class by hand — eliminates typos in key names and missing fields.

Firebase and Firestore

Firestore documents are JSON objects. Generating a Dart model from a sample document snapshot gives you a typed class with fromJson and toJson that maps directly to Firestore's DocumentSnapshot.data() and doc.set(model.toJson()) pattern.

State management models

Provider, Riverpod and Bloc all work best with immutable model classes. The copyWith method generated by JSONshift follows the same pattern as Flutter's own ThemeData and TextStyle — making your models first-class citizens in any state management architecture.

Rapid prototyping

When building a proof of concept or a new feature, generating model classes from mock JSON lets you start writing UI code immediately — without setting up json_serializable, running build_runner, or waiting for code generation. Ship the prototype, refine the model later.

Generation options explained

What each setting produces in the Dart output.

OptionValuesWhat it does
Root class name Any valid Dart identifier The name of the top-level Dart class. Use PascalCase — e.g. UserProfile, ProductDetail. Nested object classes are derived automatically from the key name: a key address produces a class named Address.
Null safety Enabled · Disabled Enabled marks nullable fields with ? — required for Dart ≥ 2.12 and all current Flutter versions. Disabled generates pre-null-safety code where all fields are non-nullable — use this for legacy projects that haven't migrated yet.
toJson method Include · Omit Include generates a Map<String, dynamic> toJson() method for serialisation — required for POST requests, Firestore writes and local storage. Omit generates a read-only model with only fromJson — suitable when you only ever receive data from the API.
copyWith method Include · Omit Include generates a copyWith() method that returns a new instance with specified fields replaced — the standard pattern for immutable state in Flutter. Omit keeps the class minimal if you don't use immutable state management.
Field modifiers final · var final makes all fields immutable after construction — the recommended approach for Flutter models used with state management. var makes fields mutable — useful for form models or when you need to update individual fields after instantiation.
Related JSON tools

Other free converters you might need in your Flutter workflow.

Popular searches
json to dart converter json to dart flutter json to dart model class convert json to dart online json to dart null safety json to dart fromJson flutter json model generator json to dart class generator dart model from json json to dart copyWith json to dart list flutter json serialization json to dart free online

Dart models generated
in your browser. No upload.

The entire class generation runs in JavaScript locally. Your JSON API response is parsed and traversed in your browser — it is never transmitted to any server, never stored, and gone the moment you close the tab.

The generated code follows Dart conventions: PascalCase class names, camelCase field names, factory constructors for fromJson, and Map<String, dynamic> for toJson — compatible with dio, http, json_serializable conventions and Flutter's own state management patterns.

Null safety by default
Generates correct nullable (String?) and non-nullable (String) types based on your sample JSON values — for Dart ≥ 2.12 and all current Flutter versions.
Nested classes
Each nested JSON object becomes a separate named Dart class — no Map<String, dynamic> shortcuts. Fully typed from top to bottom.
Flutter-ready patterns
copyWith, fromJson factory, toJson method — the exact patterns used by Flutter's own classes and recommended by the Flutter team.
47 tools, always free
No file size limits, no watermarks, no account. Funded by non-intrusive display advertising only.
Frequently asked questions
Common questions about generating Dart model classes from JSON.
How do I convert JSON to Dart?
Paste your JSON into the converter, set the root class name, choose your options (null safety, copyWith, toJson), and click Generate. Copy the Dart class directly into your Flutter project. The conversion runs entirely in your browser — no upload required.
Does the generated Dart code support null safety?
Yes. With null safety enabled, fields whose sample values are null are typed as nullable (String? name) and fields with non-null values are typed as required (String name). Toggle null safety off to generate pre-null-safety code for older Flutter projects that haven't migrated yet.
How are nested JSON objects handled?
Each nested JSON object generates a separate Dart class. A user object with an address nested object produces a User class and an Address class, each with their own fromJson and toJson methods. All classes are output together so you can drop them all into one file.
How are JSON arrays typed in the Dart output?
Arrays of objects become List<ClassName> with .map((e) => ClassName.fromJson(e as Map<String, dynamic>)).toList() in fromJson. Arrays of primitives become List<String>, List<int>, List<double> or List<bool> based on the inferred element type. Mixed or empty arrays become List<dynamic>.
What is copyWith and should I include it?
copyWith returns a new instance of the class with specified fields replaced — standard practice in Flutter for immutable state management with Provider, Riverpod or Bloc. Enable it if you use immutable models. The generated copyWith accepts all fields as optional named parameters, mirroring Flutter's own copyWith pattern.
Is the JSON to Dart converter free?
Yes, completely free. No file size limits, no account required. JSONshift is funded by non-intrusive display advertising.
Go up