Skip to the content.


A Dart to generate toDynamoJson and fromDynamoJson support methods, similar to json_serializable, specifically supporting the [DynamoDB] attribute values.


Add dynamo_json to your pubspec.yaml as shown below or run dart pub add dynamo_json

  dynamo_json: ^0.0.1


Import it in your Dart code and use it with your objects like in the example below. You can see the generated code example if you like.

import 'dart:convert'; // You'll need this if you use `dynamic` fields
import 'package:dynamo_json/dynamo_json.dart';

part 'example.g.dart';

class Person {
  final String firstName, lastName;
  final DateTime? dateOfBirth;
  final List<Person> relatives;
  final dynamic stateBucket;

  // Explicitly ignore because it's explicitly set.
  // In general, `late` fields are supported.
  late final bool hasState;

    required this.firstName,
    required this.lastName,
    this.relatives = const [],
  }) {
    hasState = stateBucket != null;

  factory Person.fromDynamoJson(Map<String, dynamic> json) =>

  Map<String, dynamic> toDynamoJson() => _$PersonToDynamoJson(this);


Can only be used on classes to indicate the need for (de)serialization support.


Can only be used on fields to indicate they should not be considered by the generated code.


For details, see the documentation.