Report Tool or Give Us Suggestions

YAML to Dart POJO Generator

Generate Dart data classes with fromJson/toJson maps from YAML samples in the browser.

L ading . . .

Generate Dart data classes from a YAML sample with fromJson and toJson helpers ready to drop into a Flutter app or pure Dart project. Paste a YAML mapping, pick a root class name, and the tool walks the parsed shape to emit nested classes and typed fields client-side.

What the tool generates

  • Immutable Dart classes with final fields and a named constructor where every field is required.
  • fromJson factory that maps each YAML key back into the typed field via Map<String, dynamic> casts.
  • toJson method returning a Map<String, dynamic> with the original YAML keys preserved.
  • Nested classes for sub-mappings and List<T> typing inferred from the first non-null array element.

Why convert YAML to Dart?

Flutter teams often receive sample fixtures or API contracts in YAML form because YAML is friendlier to humans than JSON for hand-authored mocks. The shape stays the same once parsed, so this tool gives you the same scaffold that a typical json_serializable setup would produce manually—useful for spike work, models you do not want to annotate, or quick reference snippets in pull requests.

Type inference

  • true / falsebool
  • Integer values → int
  • Decimal numbers → double
  • Strings → String
  • Mappings → nested Dart class named after the parent field
  • Empty or all-null arrays → List<dynamic>

Identifier safety

Field names are converted to camelCase and Dart reserved words (such as class, final, new) are suffixed with Value so the output compiles. Original YAML keys are preserved in the fromJson/toJson maps so serialization round-trips unchanged.

Known limitations

Heterogeneous arrays (mixed primitives and objects) infer their item type from the first non-null element. Anchors and aliases are expanded by js-yaml at parse time. Tagged custom YAML types fall back to dynamic. For polymorphic discriminated unions, add the appropriate switch logic after generation.

Frequently Asked Questions

Does the generated code depend on json_serializable?

No. The classes are plain Dart with hand-written fromJson and toJson, so they work without code generation or extra packages.

Are the fields nullable or required?

Fields are non-nullable and marked required in the constructor. Wrap the type with ? manually if you expect nulls (for example String?) and update the fromJson cast accordingly.

How do nested objects map?

Each nested mapping becomes its own class, named after the parent class and the field. Lists of objects use List<Type> with the nested class as the item type.

Is my YAML uploaded anywhere?

No. Parsing happens entirely in the browser with js-yaml. Nothing is sent to any server.

Can I edit the root class name?

Yes. The root class name field controls the top-level class identifier. It is automatically converted to PascalCase before emission.

logo OnlineMiniTools

OnlineMiniTools.com is your ultimate destination for a wide range of web-based tools, all available for free.

Feel free to reach out with any suggestions or improvements for any tool at admin@onlineminitools.com. We value your feedback and are continuously striving to enhance the tool's functionality.

© 2026 OnlineMiniTools . All rights reserved.

Hosted on Hostinger

v1.10.0