Json 2 Dart Command line utility

Important note

There is already a package called json2dart so this package will be called json2dartc !

This project was made using javiercbk's json_to_dart package ! This CLI was made to directly convert JSON stuctures into Dart classes . I personally don't like build runners and json serializers so I made this for my workflow . Feel free to open issues and submit PRs .

How to use

Install this via pub

pub global activate json2dartc


json2dartc -u https://reqres.in/api/users -m get -e data -n Example

Null safety

To turn on null safe code generation , add the flag --null-safe , Example :

json2dartc -u https://reqres.in/api/users -m get -n Example --null-safe


-u, --api        API Endpoint required to grab the json from
-e, --entry      Entry point for json data structure , e.g data.data will get the nested data array/object from API response
-n, --name       Name of your data class
                 (defaults to "AutoGenerated")
-h, --headers    Headers for your API endpoint
-m, --method     Method for http request , defaults to GET
                 (defaults to "GET")
-utruerequired fieldhttps://reqres.in/api/users
-efalse''datait's used for special access in json data , e.g data.data will access nested data object within data object

Upcoming plans

  • x Null safety support
  • Tool itself written with null safety
  • Private memmbers option
  • Option to load json from a file