Search packages, repositories and app categories

Package detailsv1.0.5

json_to_dart

A library that generates Dart classes (parse and generator included) from a json string.

AndroidiOSmacOSWindowsLinux
30-day downloads
35
Likes
6
Pub points
105

Install package

flutter pub add json_to_dart

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Flutter/Dart package that automatically generates Dart classes from JSON strings, including parsing logic and serialization utilities. It simplifies working with JSON data by converting it into well-structured, type-safe Dart models. The tool supports both code generation and runtime parsing, making it ideal for rapid development and maintaining clean, consistent data models. It integrates seamlessly with Flutter projects via pub.dev.

Use cases

  • Generating models from API responses
  • Automating boilerplate for JSON parsing
  • Simplifying data layer development
  • Enabling type safety in JSON handling
  • Streamlining app state management

Key features

  • Auto-generates Dart classes from JSON
  • Includes parse and toJson methods
  • Supports nested objects and lists
  • Provides command-line interface
  • Integrates with Flutter pub package system

Suitable for

  • Developers using JSON APIs
  • Teams prioritizing code consistency
  • Projects requiring fast model creation
  • Flutter apps with heavy JSON usage
  • Frontend developers focused on efficiency

Considerations

  • Requires valid JSON input
  • Manual adjustments may be needed for complex structures
  • Not suitable for dynamic or unpredictable JSON formats
  • Limited to static code generation
  • Best used during early development stages

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

JSON to Dart

Build Status

Given a JSON string, this library will generate all the necessary Dart classes to parse and generate JSON.

This library is designed to generate Flutter friendly model classes following the flutter's doc recommendation.

Caveats

  • When an empty array is given, it will create a List. Such weird behaviour should warn the user that there is no data to extract.
  • Equal structures are not detected yet (Equal classes are going to be created over and over).
  • Properties named with funky names (like "!breaks", "|breaks", etc) or keyword (like "this", "break", "class", etc) will produce syntax errors.
  • Array of arrays are not supported:
[[{ "isThisSupported": false }]]
[{ "thisSupported": [{ "cool": true }] }]

Categories

Dependencies

Dependency list 3 items

Source repository

Projects using this package

No data available yet.