Report Tool or Give Us Suggestions

YAML to JavaScript POJO Generator

Generate JavaScript ES6 classes from YAML samples with constructor and toJSON in the browser.

L ading . . .

Generate JavaScript ES6 classes from a YAML sample with a typed constructor, a static fromJSON() factory, and a toJSON() serializer. Paste a YAML mapping, pick a root class name, and the tool parses the YAML with js-yaml and walks the resulting structure to emit one class per nested mapping—all in your browser.

What the tool generates

  • ES6 class definitions with destructuring constructors so you can build instances directly from plain objects.
  • JSDoc @type annotations for every property to drive editor autocomplete and type-aware tooling.
  • static fromJSON(data) factory that recursively rebuilds nested classes and arrays of classes.
  • toJSON() method returning a plain object with the original keys preserved.
  • CommonJS module.exports listing every generated class for Node.js or bundler-based projects.

Why convert YAML to JavaScript classes?

YAML is the de-facto language for human-authored configuration—CI pipelines, Kubernetes manifests, Docker Compose files, and even API fixtures. When that configuration is consumed from a JavaScript or Node.js codebase, wrapping the parsed YAML in real classes adds discoverability and editor support without changing the data on the wire. The generated fromJSON/toJSON pair lets you round-trip YAML → classes → YAML cleanly with js-yaml.

Type inference

  • true / falseboolean
  • Integer values → number (int) JSDoc tag
  • Decimal numbers → number (float) JSDoc tag
  • Strings → string
  • Mappings → nested ES6 class
  • Sequences → Array<T> typed by the first non-null element

Identifier safety

Keys are converted to camelCase for property and constructor parameter names. JavaScript reserved words (such as class, delete, new) are suffixed with Value so the class compiles cleanly. Keys that are not valid JavaScript identifiers are handled with quoted string keys and bracket access in fromJSON/toJSON.

Known limitations

Heterogeneous sequences infer their item type from the first non-null entry. YAML anchors and aliases are expanded by js-yaml at parse time. Custom YAML tags are dropped to plain values, so the inferred type falls back to any if needed.

Frequently Asked Questions

Do the generated classes require TypeScript?

No. They are plain JavaScript ES2015+ classes. Type hints are emitted through JSDoc @type annotations so editors like VS Code give autocomplete without any build step.

How do nested mappings map to classes?

Each nested mapping becomes its own class named after the parent class and the key. fromJSON() recursively rebuilds nested classes; sequences of mappings become arrays of class instances.

Can I serialize back to YAML?

Yes. Call instance.toJSON() to get a plain object, then pass it to yaml.dump() from js-yaml. The keys round-trip unchanged because they are preserved in toJSON().

Is my YAML uploaded anywhere?

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

Can I customize the root class name?

Yes. Use the Root class name input—the value is converted to PascalCase and used for both the top-level class and as a prefix for nested classes.

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