# JSON to Dart model

> Generate a Dart model from a JSON object.

[Open tool](https://www.toolcabana.com/tk/json-to-dart) · [Developer and data](https://www.toolcabana.com/tk/category/developer-and-data)

Tool ID: json-to-dart. Requested language: tk. Description language: en. Complete guide translation: no; untranslated sections use English.

## Overview (en)

JSON to Dart model generates a Dart class from a root JSON object, with final fields, a constructor with required named parameters, a fromJson factory and a toJson method. Strings, booleans, integers and doubles get matching Dart types, while nested arrays and objects use dynamic collection types. Reserved Dart words are rejected as names.

## Supported tasks (en)

Generates a root Dart class with fromJson and toJson methods. Nested arrays and objects use dynamic collection types. Reserved identifiers are rejected; review generated code before use.

## Steps (en)

1. Type or paste your source, or load an example.
2. Change the basic settings or open Advanced mode to fine-tune the result.
3. Review and copy or download your result. Pause Live results to run manually. Sources or individual settings above 20,000 characters require an explicit run.

## Settings

- Root type name (en; key: name; type: text)

## Limitations (en)

Text operations generally accept up to 2,000,000 characters. Individual parsers, generators and formulas apply additional limits shown by their controls.

## Example input

```text
{"name":"ToolCabana","count":2}
```

## Privacy and connections (en)

This operation processes its source in your browser. Copy and download are explicit actions; source input is not saved in an account or history.

## Questions (en)

### How do I create a Dart model class from JSON?

Paste a JSON object, set the Root type name for the class, and run the tool. The output contains the fields, constructor, fromJson factory and toJson method.

### Why does JSON to Dart say my keys are invalid?

Each key becomes a field name, so it must start with a letter and contain only letters, digits and underscores, and it cannot be a reserved Dart word such as class or default.

### How are nested objects typed in the Dart model?

Nested objects are typed as a Map with String keys and dynamic values, and arrays as a List of dynamic values. Null values become dynamic, so review those fields before using the class.

### Where is my input processed?

This operation processes its source in your browser. Copy and download are explicit actions; source input is not saved in an account or history.

### What are the input limits?

Text operations generally accept up to 2,000,000 characters. Individual parsers, generators and formulas apply additional limits shown by their controls.

## Related tools

- [JSON to TypeScript](https://www.toolcabana.com/tk/json-to-typescript)
- [JSON to Excel](https://www.toolcabana.com/tk/json-to-excel)
- [Excel to JSON](https://www.toolcabana.com/tk/excel-to-json)
- [XML to JSON](https://www.toolcabana.com/tk/xml-to-json)
