JSON to Elm Record Type
Turn a JSON sample into a Elm type alias in your browser. Absent and null fields stay distinct, and nothing is uploaded.
What the JSON to Elm generator does
Each object becomes a type alias for a record. Elm has no null and no absent value, so both cases become Maybe: a key that was null and a key that was missing both decode as Nothing. Type application in Elm needs parentheses around a nested application, which is why a list of lists is written List (List Int) rather than List List Int. The module exposes every generated alias so it can be imported as one.
How to use it
JSON to Elm Record Type: paste the JSON into the box above, set Root type name (default "Root"), and press Run to get the Elm type alias below.
Worked example
Input:
{
"id": 42,
"displayName": "Ada Lovelace",
"active": true,
"score": 9.5,
"tags": [
"math",
"engine"
],
"address": {
"city": "London",
"country": "GB"
},
"projects": [
{
"name": "Analytical Engine",
"year": 1843
},
{
"name": "Note G",
"year": 1843,
"notes": "first published algorithm"
}
],
"nickname": null
}
Output:
-- Generated from a JSON sample in the browser by AllTools — nothing was uploaded.
-- Rename and adjust to taste; the shape is inferred from one example, not a schema.
module Model exposing (Root, Address, Project)
import Json.Decode exposing (Value)
type alias Root =
{ id : Int
, displayName : String
, active : Bool
, score : Float
, tags : List (String)
, address : Address
, projects : List (Project)
, nickname : Maybe (Value)
}
type alias Address =
{ city : String
, country : String
}
type alias Project =
{ name : String
, year : Int
, notes : Maybe (String)
}
Why it runs in your browser
The conversion happens on this page with JavaScript. Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere. The page reads JSON and returns Elm type alias; reloading the page discards both.
Each object becomes a type alias for a record. Elm has no null and no absent value, so both cases become Maybe: a key that was null and a key that was missing both decode as Nothing. Type application in Elm needs parentheses around a nested application, which is why a list of lists is written List (List Int) rather than List List Int. The module exposes every generated alias so it can be imported as one.
Turn a JSON sample into a Elm type alias in your browser. Absent and null fields stay distinct, and nothing is uploaded.
How to use it
JSON to Elm Record Type: paste the JSON into the box above, set Root type name (default "Root"), and press Run to get the Elm type alias below.
Why it runs in your browser
The conversion happens on this page with JavaScript. Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere. The page reads JSON and returns Elm type alias; reloading the page discards both.
What to Expect
Best for
- Converting JSON to Elm type alias when the data is already on screen.
What this tool keeps
- Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere.
Sample input
{ "id": 42, "displayName": "Ada Lovelace", "active": true, "score": 9.5, "tags": [ "math", "engine" ], "address": { "city": "London", "country": "GB" }, "projects": [ { "name": "Analytical Engine", "year": 1843 }, { "name": "Note G", "year": 1843, "notes": "first published algorithm" } ], "nickname": null }
Sample output
-- Generated from a JSON sample in the browser by AllTools — nothing was uploaded. -- Rename and adjust to taste; the shape is inferred from one example, not a schema. module Model exposing (Root, Address, Project) import Json.Decode exposing (Value) type alias Root = { id : Int , displayName : String , active : Bool , score : Float , tags : List (String) , address : Address , projects : List (Project) , nickname : Maybe (Value) } type alias Address = { city : String , country : String } type alias Project = { name : String , year : Int , notes : Maybe (String) }
Frequently asked questions
How do I use the json to elm record type?
JSON to Elm Record Type: paste the JSON into the box above, set Root type name (default "Root"), and press Run to get the Elm type alias below.
Is my input uploaded?
No. The text is parsed on this page with JavaScript and is never posted to a server.
Is there a size limit?
Yes: 5 MB per run. Larger input is refused with a message rather than freezing the tab.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.