Runs 100% in your browser — your JSON is never uploaded

JSON to Dart Model Converter

Paste an API response and get clean, null-safe Dart model classes for Flutter — plain fromJson/toJson, json_serializable, Freezed or Equatable, with nested objects split into their own classes.

Convert JSON to Dart classes

JSON

Waiting for JSON

Dart

Your Dart classes will appear here.

Generation settings

In short: what this converter does

The SeeB4Coding JSON to Dart Model Converter turns any JSON payload into ready-to-use Dart model classes for Flutter, entirely inside your browser. Paste a response, pick an output style, and copy the result — no sign-up, no upload, no build tooling required to try it.

  • Four output styles: plain Dart, json_serializable, Freezed and Equatable.
  • Null safety by default: keys that can be absent or null are generated as nullable (String?); the rest are required.
  • Nested structures: every nested object becomes its own class; arrays of objects become List<Class> with merged item shapes.
  • Idiomatic naming: snake_case keys become lowerCamelCase fields, with the original key preserved in the mapping.
  • Type inference: int, double, num, bool, String, DateTime, List and dynamic.
  • Privacy: the conversion is pure client-side JavaScript — your JSON never leaves the device.

How to convert JSON to a Dart model

Three steps, about a minute.

Paste your JSON

Paste an API response, drop a .json file onto the editor, or load the sample. The status bar validates as you type and points at the exact line of any syntax error.

Pick a style and tune it

Choose plain Dart, json_serializable, Freezed or Equatable. Set the root class name, then toggle null safety, copyWith, date detection, equality and doc comments.

Copy or download

Copy the generated classes to the clipboard or download a .dart file straight into your Flutter lib/models folder. Every conversion is saved to local history.

Which Dart model style should you pick?

All four produce working models. The difference is how much they give you, and what they cost in dependencies and build time.

Comparison of the four output styles this converter generates.
Style Dependencies Needs build_runner Immutable Value equality Best for
Plain Dart None No Optional Optional Small apps, packages, quick prototypes, anywhere you do not want codegen.
json_serializable json_annotation, build_runner Yes Optional No Large APIs where you want serialization generated but keep control of the class body.
Freezed freezed_annotation, freezed, build_runner Yes Yes Yes State management with Bloc or Riverpod, where copyWith, equality and unions all matter.
Equatable equatable No Optional Yes Bloc states and comparisons when you want equality without a code generation step.

Rule of thumb: start with plain Dart. Move to json_serializable when hand-written fromJson becomes a chore, and to Freezed when your models are app state rather than just transport objects.

JSON to Dart type mapping

How each JSON value is translated, and what to watch out for.

Type inference rules used by the converter.
JSON value Dart type Notes
"hello"StringAny text value.
"2024-05-31T12:04:00Z"DateTimeOnly when date detection is on. Parsed with DateTime.parse, written with toIso8601String.
42intWhole numbers. Switch number handling to num if the API can also send decimals.
4.2doubleDecoded as num then converted with toDouble(), since JSON 4.0 can arrive as an int.
truebool
nulldynamicA key that is only ever null carries no type information. Supply a populated sample for better output.
{ ... }MyClassGenerated as its own class, named after the key holding it.
[ { ... } ]List<Item>Item shapes are merged across the array; keys missing from some items become nullable.
[ 1, 2, 3 ]List<int>Mixed-type arrays fall back to List<dynamic>.
[]List<dynamic>An empty array gives no element type.

Getting accurate models

The generated code is only as good as the sample you paste. A few habits make a large difference.

Use a fully populated response

Pick a sample where optional fields are filled in. Nulls and missing keys are what produce dynamic fields you then have to fix by hand.

Include several list items

Paste an array with two or three different items. The converter merges their shapes, so genuinely optional keys are correctly marked nullable.

Prefer num for money

An API that returns 10 today can return 10.5 tomorrow. Setting number handling to num avoids a runtime cast error in production.

Frequently asked questions

Everything people usually ask about generating Dart models from JSON.

Is my JSON uploaded to a server?

No. All parsing and code generation runs in your browser with JavaScript. Your JSON never leaves your device, so production API responses, tokens and customer data stay private. Once the page has loaded you can even go offline and it keeps working.

Which Dart code style should I choose?

Use plain Dart when you want zero dependencies and no build step. Use json_serializable when you want fromJson and toJson generated but the class body hand-written. Use Freezed when you want immutability, copyWith, equality and unions from one package. Use Equatable when all you need is value equality with no code generation.

How does the converter handle nested JSON objects?

Every nested object becomes its own Dart class, named after the key that contains it. Arrays of objects produce a List of that class, and the item shapes are merged, so a key that is missing from some items is generated as a nullable field. With Merge identical nested classes enabled, two nested objects with the same field signature collapse into a single reused class instead of two near-duplicates.

What happens to null values in my JSON?

A key whose only observed value is null carries no type information, so it is generated as dynamic. Keys that are sometimes null and sometimes typed become nullable fields of that type, such as String? or int?. Paste a sample with populated values to get the most accurate types.

Does it convert snake_case keys to camelCase fields?

Yes. snake_case, kebab-case and PascalCase keys become idiomatic Dart lowerCamelCase field names. The original key is preserved in the generated fromJson/toJson code, or as a @JsonKey(name: '...') annotation in the json_serializable and Freezed output, so the wire format is unchanged. Set field naming to Keep original JSON keys to turn this off.

Can it detect dates in JSON?

Yes. With date detection enabled, strings matching ISO 8601 forms such as 2024-05-31 or 2024-05-31T12:04:00Z are typed as DateTime, parsed with DateTime.parse and serialized back with toIso8601String(). Unix timestamps are left as numbers, since an integer cannot be told apart from any other number.

Why is a number typed as double instead of int?

JSON has a single number type, so the converter infers from your sample: a value with a decimal point becomes double, a whole number becomes int. Because a JSON 4.0 may decode as an int at runtime, generated double fields are read as num and converted with toDouble(). For money and measurements, choosing num in the settings is the safest option.

Do I need build_runner for the generated code?

Only for json_serializable and Freezed, which emit part files. Add the packages to pubspec.yaml, then run dart run build_runner build --delete-conflicting-outputs. Plain Dart and Equatable output compiles as-is with no build step.

Can I convert a top-level JSON array?

Yes. Paste an array and the converter merges the item shapes into a single class named after your root class name. In your code, map the decoded list with (jsonDecode(body) as List).map(MyClass.fromJson).toList().

Where is my conversion history stored?

In your browser only, using localStorage. The last 20 conversions are kept on this device, are never sent anywhere, and can be cleared at any time from the history panel.

Is the JSON to Dart Model Converter free?

Yes. Completely free, no sign-up, and no limit on payload size or on how many models you generate.

Other browser-based utilities from SeeB4Coding.