Avro Schema to JSON
Generate a sample JSON value from an Avro schema: records, enums, arrays, maps, unions and the primitive types, deterministically.
What the Avro Schema to JSON does
A record becomes an object with its fields in schema order, and a union takes its first non-null branch, because null is not a useful sample. An array gets one item and a map gets one key, which is the smallest value that satisfies the type.
Strings use the field's own name, so a sample reads as documentation: a name field holds "name".
A logical type is not interpreted: uuid, timestamp-millis and decimal are refused by name rather than approximated as strings, because the sample would then be valid JSON and invalid Avro. fixed becomes a string of the right length.
How to use it
Paste the schema into the Avro schema box, or press Run with the example already there.
Read the Sample JSON below: one value per record field, in schema order.
Check a Sample JSON array field — it holds one item, which is the smallest valid value.
Worked example
Input:
{
"type": "record",
"name": "U",
"fields": [
{
"name": "id",
"type": "long"
},
{
"name": "name",
"type": "string"
},
{
"name": "tags",
"type": {
"type": "array",
"items": "string"
}
}
]
}
Output:
{
"id": 0,
"name": "name",
"tags": [
"tags"
]
}
Why it runs in your browser
The result is produced on this page with JavaScript, so it works offline after the page loads and nothing you enter is sent anywhere.
A sample value shaped by an Avro schema: one field per record field, an array with one element, a map with one key, and an enum's first symbol.
The output is deterministic — the same schema always yields the same sample — so it can be committed as a fixture without churn.
What it does, and what it does not
A record becomes an object with its fields in schema order, and a union takes its first non-null branch, because null is not a useful sample. An array gets one item and a map gets one key, which is the smallest value that satisfies the type.
Strings use the field's own name, so a sample reads as documentation: a `name` field holds `"name"`.
A logical type is not interpreted: `uuid`, `timestamp-millis` and `decimal` are refused by name rather than approximated as strings, because the sample would then be valid JSON and invalid Avro. `fixed` becomes a string of the right length.
How to use Avro Schema to JSON
Paste the schema into the Avro schema box, or press Run with the example already there.
Read the Sample JSON below: one value per record field, in schema order.
Check a Sample JSON array field — it holds one item, which is the smallest valid value.
What to Expect
Best for
- Producing a fixture that matches an Avro schema
- Seeing the shape a schema describes
Not ideal for
- Logical types such as uuid or decimal, which are refused
- A realistic value, which needs a faker with a schema
What this tool keeps
- Field order from the schema
- One item for every array and one key for every map
What may need cleanup
- A logical type needs a hand-written sample
- A union's non-first branch needs choosing by hand
Common errors
- The page refuses it: Avro type "uuid" is not modelled
Example use cases
- Building a message fixture for a Kafka test
- Checking a schema's nesting before writing code
Sample input
Avro schema: { …
Sample output
Sample JSON: { …
Who this is for
- Data engineers working with Avro
- Developers testing a Kafka consumer
Frequently asked questions
Why are logical types refused?
A uuid written as a random string is valid JSON and invalid Avro. Refusing it by name is honest; the page does not know which form your producer writes.
How does a union choose a branch?
It takes the first branch that is not null. A sample of null says nothing about the schema, and most unions put null first for optionality.
Is a map filled with one key?
Yes. A map needs at least one entry to show its value type, and the key is example with a value generated from the map's value type.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.