YAML to Elm
Paste YAML and get ready-to-use Elm type alias declarations inferred from your data's structure.
Example
Input YAML:
name: Acme
count: 3
active: true
owner:
id: 1
email: [email protected]
Generated Elm:
type alias Owner =
{ id : Int
, email : String
}
type alias Root =
{ name : String
, count : Int
, active : Bool
, owner : Owner
}How it works
The tool parses your YAML with js-yaml, infers an Elm type for each value (Int/Float/Bool/String/List/record), and emits type alias definitions starting from a Root record. Nested objects become their own named type aliases.
Good to know
YAML to Elm reads a YAML document and generates matching Elm type alias declarations by inferring a type for every value it finds. It is aimed at Elm developers who receive configuration files, API fixtures, or service responses as YAML and want a head start on the record types they will decode into, instead of hand-writing every field. Everything runs in your browser via js-yaml, so the data you paste never leaves your device.
Reach for it when you are bootstrapping a JSON/YAML decoder, modeling a third-party config schema, or sketching the shape of nested data before writing Json.Decode pipelines. Because Elm has distinct numeric types, the tool reads 3 as Int and 1.5 as Float, maps true/false to Bool, quoted or plain text to String, and turns each nested object into its own named alias building up to a top-level Root record.
To read the output, start at the bottom: Root is the entry point, and every other alias above it corresponds to a nested object, named after the field that held it (a list of records is named from the singularized field, so items yields an Item alias). A few values map to placeholders you should review by hand:
List () means the source list was empty, Maybe () means the value was null, and a field that hit a Elm reserved word (like type or port) gets a trailing underscore.
Treat the result as a starting draft, not a finished model: type inference only sees the one sample you paste, so it cannot know that an empty list is really List String or that a present number is sometimes absent. Feed it a representative example with every field populated, then replace the () placeholders and tighten optional fields into proper Maybe types yourself.
Frequently asked questions
How are nested objects and lists typed?
Each nested object becomes its own type alias named after its field (e.g. owner becomes type alias Owner), and lists become List of the inferred element type. List element records are named from the singularized field name.
Does it tell Int from Float?
Yes. Whole numbers like 3 are inferred as Int and numbers with a decimal like 1.5 as Float, matching Elm's distinct numeric types. Empty lists and nulls fall back to () so the code stays valid.
Is my data uploaded anywhere?
No — this tool runs entirely in your browser. Your input never leaves your device and it works offline once loaded.
Is it free?
Yes, completely free with no sign-up and no limits.
People also ask
What is an Elm type alias?
A type alias gives a name to an existing type, most often a record. Defining `type alias Root = { name : String }` lets you refer to that record shape as `Root` throughout your code and also gives you a `Root` constructor function.
Does this tool generate JSON decoders for Elm?
No. It only produces `type alias` declarations describing the data's shape. You still need to write the corresponding `Json.Decode` (or YAML decoding) logic separately, though the generated aliases tell you exactly which fields and types to decode.
Why does Elm distinguish Int from Float?
Elm treats whole numbers and decimals as separate types for type safety, so `3` and `1.5` are not interchangeable. That is why this converter inspects each number and emits `Int` for whole values and `Float` for values with a decimal point.
What happens to null or empty values in my YAML?
A null value is typed as `Maybe ()` and an empty list is typed as `List ()`. These are valid placeholders that keep the code compiling, but you will usually want to replace them with the real element or wrapped type once you know it.
How does it name the type aliases?
Nested objects are named after the field that contains them, capitalized into PascalCase. For a list of objects, the element type is named from the singularized field (for example `items` becomes `Item`), and the top-level structure is always called `Root`.
Can I convert YAML to Elm without uploading my file?
Yes. This tool parses and converts entirely in your browser, so the YAML you paste is never sent to a server and it continues to work offline after the page has loaded.
What if a field name is an Elm reserved word?
Reserved words such as `type`, `port`, `case`, and `module` cannot be used as record field names, so the tool appends an underscore (for example `type_`) to keep the generated code valid.
Does it handle deeply nested YAML and lists of objects?
Yes. Each nested object becomes its own named alias and lists become `List` of the inferred element type, including lists of records. The inference is based on the first element of a list, so mixed-type lists may need manual adjustment.
Related tools