# JSON to Dart Class Converter

> Convert JSON objects into strongly-typed Dart Class definitions and data models.

To convert JSON to Dart Class, paste your JSON payload above and specify the root type name. The generator creates clean, idiomatic Dart Class code definitions instantly in your browser without uploading your JSON data to external servers.

**URL:** https://convertto.tech/t/json-to-dart
**Category:** Data & Format Tools (https://convertto.tech/c/data-tools)
**Privacy:** Runs entirely in the browser; no upload
**Cost:** Free, no sign-up
**Last updated:** 2026-08-01

## Key facts

- **Privacy:** Runs entirely in your browser — nothing is uploaded
- **Cost:** Free, unlimited, no sign-up

## From a JSON sample to a Dart class

The output is a class of `final` fields with a constructor whose parameters are all `required` named arguments. That shape is deliberate: it is what sound null safety pushes you toward, and it is the shape `json_serializable` and `freezed` expect to decorate. What it does not write is `fromJson` and `toJson`, because how you decode is a project decision rather than something a sample payload can answer.

## What one sample can and cannot tell it

- Nullability is inferred, not known. Dart has been non-nullable by default since 2.12, so every field arrives non-nullable. Anything the server may omit or send as `null` needs a `?` adding by hand.
- A JSON `null` carries no type information at all, so it becomes `dynamic`. That is the honest reading of the sample and almost never the type you want to ship.
- A nested object becomes its own class named after its key, and the parent holds a reference to it rather than an inline map.
- A list is typed from its first element. `List<String>` from a list of strings is right; a list mixing objects and nulls needs `List<dynamic>` or a hand-written union.
- Integer and double are told apart by whether the sample value had a fractional part. A price that happened to be `10` infers `int` and will throw the first time the API sends `10.5`. Widen it to `double` or `num`.

> **Field names are camelCased** — A `created_at` key becomes a `createdAt` field, which is what the Dart linter expects, and the original string then survives only in your decoder. If you write `fromJson` by hand, key the map lookup on the original string rather than assuming the field name matches.

Building the same model on the other side of a cross-platform app? [JSON to Kotlin](https://convertto.tech/t/json-to-kotlin) and [JSON to Swift](https://convertto.tech/t/json-to-swift) take the same payload, and [JSON to TypeScript](https://convertto.tech/t/json-to-typescript) covers the web client.

## How to use

1. Enter or paste your json.
2. Enter or paste your root type name.
3. Press Run, then download the result when it is ready.

## FAQ

### Does this JSON to Dart Class converter upload my files?

No, all type generation runs purely in JavaScript in your browser.

## Sources

- [RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format](https://www.rfc-editor.org/rfc/rfc8259) — IETF
- [Flutter: JSON and serialization](https://docs.flutter.dev/data-and-backend/serialization/json) — Google

## Related tools

- [JSON to C# Model Converter](https://convertto.tech/t/json-to-csharp): Convert JSON objects into strongly-typed C# Model definitions and data models.
- [JSON to Go Struct Converter](https://convertto.tech/t/json-to-go): Convert JSON objects into strongly-typed Go Struct definitions and data models.
- [JSON to Java Class Converter](https://convertto.tech/t/json-to-java): Convert JSON objects into strongly-typed Java Class definitions and data models.
- [JSON to Kotlin Data Class Converter](https://convertto.tech/t/json-to-kotlin): Convert JSON objects into strongly-typed Kotlin Data Class definitions and data models.
- [JSON to Mongoose Schema Converter](https://convertto.tech/t/json-to-mongoose): Convert JSON objects into strongly-typed Mongoose Schema definitions and data models.
- [JSON to Prisma Model Converter](https://convertto.tech/t/json-to-prisma): Convert JSON objects into strongly-typed Prisma Model definitions and data models.
- [JSON to Python Dataclass Converter](https://convertto.tech/t/json-to-python): Convert JSON objects into strongly-typed Python Dataclass definitions and data models.
- [JSON to Rust Struct Converter](https://convertto.tech/t/json-to-rust): Convert JSON objects into strongly-typed Rust Struct definitions and data models.
- [JSON to Swift Codable Converter](https://convertto.tech/t/json-to-swift): Convert JSON objects into strongly-typed Swift Codable definitions and data models.
- [JSON to Zod Schema Converter](https://convertto.tech/t/json-to-zod): Convert JSON objects into strongly-typed Zod Schema definitions and data models.
