What is Elm?
Elm is a strongly-typed functional language that compiles to JavaScript and is purpose-built for front-end web applications. It is famous for "no runtime exceptions" — the type system catches every malformed value at compile time. Elm enforces explicit JSON decoders so you cannot accidentally trust an external payload, which is why a converter that produces both the type and the decoder is so useful.
How do JSON decoders work in Elm?
In Elm, parsing JSON is a two-step process: parse the raw string into a Json.Decode.Value, then run a Decoder MyType against it. Decoders are first-class values you compose — Json.Decode.string, Json.Decode.int, Json.Decode.field "name" Json.Decode.string. The pipeline package (NoRedInk/elm-json-decode-pipeline) provides |> Json.Decode.Pipeline.required for ergonomic chaining, which is the style used by this generator.
Which packages do I need installed?
elm install elm/json (built-in for stdlib decoders) and elm install NoRedInk/elm-json-decode-pipeline (for the pipeline syntax used by the generator). Both are battle-tested core packages used by virtually every Elm production application.
How are nested objects handled?
Each nested JSON object becomes its own type alias plus its own decoder. The parent type references the child type by name, and the parent decoder calls the child decoder via the pipeline syntax: |> required "address" addressDecoder. The order is emitted so that nested types/decoders appear before their referencing parents — Elm requires this.
How are arrays handled?
A JSON array becomes List T in Elm. The decoder uses Json.Decode.list innerDecoder. For nested object lists, the inner decoder is the generated decoder for the child type. For mixed-type arrays use Json.Decode.value or write a custom decoder using Json.Decode.oneOf.
How do nullable fields work?
Wrap the field type in Maybe, e.g. Maybe String, and use Json.Decode.nullable. The generator emits non-Maybe types based on the sample (since the field was present); when you know a field is sometimes null or missing, change the type to Maybe T and the decoder to Json.Decode.nullable T or use Json.Decode.Pipeline.optional.
Is the JSON uploaded to your servers?
No. Conversion runs entirely in your browser via JavaScript. Open DevTools → Network and click Convert — no requests are made. Pasting JSON containing tokens or proprietary data never leaves your machine.
How do I use the generated decoder?
Pipe the decoder into Json.Decode.decodeString — Json.Decode.decodeString rootDecoder jsonString returns Result Json.Decode.Error Root. Pattern-match on Ok value or Err error in your update function. The error includes the failing path so debugging unexpected payloads is straightforward.