What is JSON to PureScript Type Generator?
This tool converts JSON data into PureScript type definitions with proper type inference. It automatically maps JSON types to PureScript types (String, Int, Number, Boolean, Maybe, Array) and handles nested objects as record types.
How to Use
- Select output format (newtype or type alias)
- Paste your JSON data into the input area
- Set the root type name
- Click "Generate" and copy the PureScript types
Why Use This Tool?
Tips & Best Practices
- Use realistic sample data for accurate type inference
- Newtype wraps the record for type safety and instance derivation
- Maybe types handle nullable JSON fields (Just value or Nothing)
- Combine with argonaut-codecs or simple-json for JSON decoding
Frequently Asked Questions
How are JSON types mapped to PureScript?
JSON strings → String, integers → Int, floats → Number, booleans → Boolean, null → Maybe type, arrays → Array type, nested objects → separate record type definitions.
What is the difference between newtype and type alias?
A newtype creates a distinct type that wraps a record, providing type safety and allowing custom typeclass instances. A type alias is just a named shorthand for the record type — it does not create a new type.
How are null values handled?
JSON null values are mapped to PureScript Maybe types. For example, a nullable string field becomes Maybe String, which can be Just "value" or Nothing.
Can I use these types with JSON decoding?
Yes, the generated types work with PureScript JSON libraries. Use argonaut-codecs, simple-json, or foreign-generic to write decoders that match these type definitions.
Is my data sent to a server?
No, all processing happens entirely in your browser. Your JSON data never leaves your device.