Skip to content

JSON to Dart Class

Generate Dart model classes with fromJson and toJson from a sample payload.

With the methods included there is no build_runner step — the serialisation is written out in full.

Quick Tool Overview

The JSON to Dart Class converter writes Flutter-ready models: final fields, a const constructor with named parameters, and fromJson and toJson methods, all null safe without any build_runner step.

What it does
Generates Dart model classes with JSON serialisation
You give it
A JSON payload, ideally an array of records
You get back
Null-safe classes with fromJson and toJson written out
Best for
Flutter apps consuming a REST API
Developer Tools Free, unlimited use No sign-up Runs in your browser

About the JSON to Dart Class

Flutter has no reflection, so every model needs its serialisation written out by hand — which is exactly the boilerplate this generates. Each class gets final fields, a const constructor with named parameters, a fromJson factory and a toJson method.

Null safety is handled properly rather than by making everything nullable. A field present in every record is non-nullable and marked required in the constructor; one that is sometimes missing gets a question mark and is optional. Nested objects call their own fromJson, and lists of objects map over the elements with the right cast, so the generated code compiles against a null-safe SDK without edits.

Key features of the JSON to Dart Class

Serialisation already written

fromJson and toJson are generated in full, so there is no code-generation step and no build_runner to keep in sync.

Real null safety

Fields present in every record are non-nullable and required; the rest are nullable and optional. It compiles against Dart 2.12 and later unchanged.

Immutable by default

Final fields and a const constructor, which is what lets Flutter skip rebuilding widgets whose inputs have not changed.

Nested lists handled

A list of objects maps over its elements with the right cast and the element type's fromJson — the pattern the Dart team documents.

Plain-data mode

Skip the methods entirely if you do use a code generator and only want the field declarations.

How to use the JSON to Dart Class

  1. 1

    Paste the JSON

    A real API response is ideal; an array detects optional fields.

  2. 2

    Name the root class

    Nested classes are named from the keys that hold them.

  3. 3

    Choose the methods

    Keep fromJson and toJson, or generate plain data classes if you use a code generator instead.

  4. 4

    Copy into your project

    Paste into a .dart file under lib/models.

Frequently asked questions

No. The point of this output is that the serialisation is already written, so there is no build_runner step. Use json_serializable instead when you have dozens of models and want them regenerated on every schema change.

Reviews of the JSON to Dart Class

What people who use the JSON to Dart Class think of it. Reviews come from visitors and are posted as written.

No ratings yet

Yours would be the first.

  • 5 0 reviews rated 5 stars
  • 4 0 reviews rated 4 stars
  • 3 0 reviews rated 3 stars
  • 2 0 reviews rated 2 stars
  • 1 0 reviews rated 1 star

Write a review

Used this tool? Your rating helps the next person decide.

Your rating

Plain text only — links, email addresses and HTML are not accepted. Your name and review are shown publicly; nothing else is collected. See the privacy policy.

0 reviews

Newest first

No reviews yet

Be the first to rate the JSON to Dart Class. It takes half a minute and no account.

Write the first review

More developer tools