Elixir to JSON Converter

Paste an Elixir struct or map. Get JSON back.

Input

Output

Paste your Elixir code on the left and press Convert.

Or drop a file on this box, , or .

What this tool does

If you have got an Elixir struct and want JSON without pulling in Jason or Poison just for a quick conversion, paste it here and get the JSON back. Works for a single %Order{} literal, a map, a keyword list, a nested chain of structs, or even a list of maps with different shapes.

Output matches what Jason.encode!/1 would give you once a struct has a @derive Jason.Encoder. The __struct__ field is dropped, atom keys become JSON string keys, and nested structs flatten into nested JSON objects. Lists become JSON arrays, nil becomes null, true/false map straight across, integers stay integers, floats stay floats.

Keyword lists ([key: value, other: 1]) emit as JSON objects: the standard Elixir convention. Binary strings and charlists both convert to JSON strings. DateTime, Date, NaiveDateTime, and Time are emitted as ISO-8601 strings per RFC 3339. Tuples become JSON arrays (same fallback Jason uses with a custom encoder).

How to use it

Three steps. Works for a one-line map or a Phoenix context module full of structs.

1

Paste your Elixir (or try the sample)

Drop your code into the left editor. A struct literal, a map, a keyword list, a nested struct, or a defstruct with an instance: all fine.

Leave the %ModuleName{} syntax, pipes, and defstruct declarations as they are. The parser understands them.

2

Hit Convert

Press the green Convert button. The module and the struct literal go to the backend, which drops __struct__, turns atom keys into strings, writes nil as null and returns the JSON.

3

Copy the JSON

Grab the indented JSON from the right panel. Drop it into a Phoenix API test, an ExUnit fixture, or a shared schema for a GraphQL endpoint.

When this actually comes in handy

Phoenix API fixtures

You have a context schema and want a JSON fixture for a controller test. Paste the struct, save the JSON, done, no need to compile and encode in IEx.

GraphQL response shape

Building an Absinthe resolver: want to sanity-check the JSON shape a given struct will produce before wiring the resolver function.

Documenting Ecto schemas

An Ecto schema struct is essentially a JSON contract. Convert to JSON once, commit as API docs, keep it in sync when the schema changes.

Cross-language handoff

Your Elixir service hands data to a Python ML pipeline. Paste a sample struct to see the JSON the downstream team will consume.

Common questions

Does it match Jason.encode!/1?

That is the target. Structs lose __struct__, atom keys become string keys, nested structs flatten into nested objects. The same output you would get with @derive Jason.Encoder on every struct in the tree.

How are atoms handled?

Atom map keys become JSON string keys. Atom values become JSON strings containing the atom name (e.g. :active becomes "active"): same behaviour as Jason.

What about tuples?

Tuples become JSON arrays ({1, 2, 3} → [1, 2, 3]). Strictly speaking Jason needs a custom encoder for tuples; this tool picks the common-sense default so your output is not missing data.

Keyword lists vs maps: any difference?

Both emit as JSON objects. A keyword list [name: "Ava", id: 1] and a map %{name: "Ava", id: 1} produce identical JSON. Duplicate keys in a keyword list keep the first occurrence.

How are DateTime and Decimal handled?

DateTime/Date/NaiveDateTime/Time become ISO-8601 strings. Decimal values emit as JSON numbers (or strings if you prefer numeric-string safety: depends on the shape). Same as what you would get from Jason with the proper encoders derived.

Is my code stored?

The snippet is sent to the backend for the conversion and not stored. Seed files and IEx history often contain real customer rows, so replace those with made-up values before pasting.

Other tools you may need

Once your struct is JSON, these help you check it or move it into the config and markup formats other services expect: