JSON → Elixir structs
ClientPaste JSON to get defmodule blocks with defstruct and @derive Jason.Encoder—field names use snake_case atoms; refine with Ecto or explicit decoding for real APIs.
Learn more: JSON and Elixir
Emit `defmodule` structs with `@derive Jason.Encoder` and snake_case atoms—pair with Jason or Ecto for decoding and validation.
Scope
Nested JSON objects become separate modules; nested maps decode as maps unless you add custom Jason.Decoder implementations or Ecto embedded schemas.
JSON → Elixir
?
Parses JSON in your browser and emits classes inferred from the sample shape. Nested objects become nested types; arrays use the first element only to guess item shape. Nothing is uploaded.
defstruct with @derive Jason.Encoder targets encoding; pair with Jason.decode! or Ecto embeds when you need validation.
Common use cases
- Sketch structs for Phoenix contexts or scripts that consume JSON APIs before adding changesets.
- Compare inferred shapes with API docs when keys use snake_case in Elixir and camelCase in JSON.
- Share sample payloads with teammates as module-shaped notes in reviews.
Common mistakes to avoid
Expecting embedded structs without custom decoding
Nested maps decode as plain maps unless you implement Jason.Decoder or cast through Ecto.
Ignoring atom table limits
Converting arbitrary JSON keys to atoms is unsafe at large scale; use string keys or explicit allowlists in production.
FAQ
Is Elixir generation local?
Yes. Code is produced entirely in your browser.
Does this add @type specs?
The comment block hints at types; add @type and @spec as you refine contracts.
More tools
Related utilities you can open in another tab—mostly client-side.
JSON → Ruby classes
ClientRuby classes with attr_accessor from sample JSON—snake_case symbols, local only.
JSON → Dart classes
ClientDart classes with final fields from sample JSON—Flutter-friendly scaffold, local only.
JSON → Scala case classes
Clientfinal case class scaffolding from sample JSON—Seq types, local only.
YAML ↔ JSON
ClientYAML to JSON and JSON to YAML online—format, validate, convert locally.