Loading Avro Schema Generator...

Generate Avro Schemas from JSON - Complete Guide

Step 1

Input Your JSON Data

Get your JSON data ready for schema generation. You have several convenient options:

•
Paste directly: Copy your JSON data from any source
•
Upload file: Click the Upload button to select a .json file
•
Try sample: Click the Sample button to see a working example
•
Configure schema: Set custom schema name and namespace for your organization

JSON input example:

{
  "id": 1,
  "name": "Elara Quinn",
  "email": "[email protected]",
  "active": true
}
Step 2

Automatic Schema Generation

Watch as your JSON is transformed into a valid Apache Avro schema. The generator provides:

•
Type inference: picks int, long, double, string or boolean from the values in every record
•
Nested structures: nested objects become their own named records, lists become arrays, and fields missing from some records become optional
•
Kafka ready: Compatible with Kafka Schema Registry and Confluent Platform
•
Checked before you see it: the schema is compiled with avsc and every input record is validated against it

Generated Avro schema example (the real output also adds a short doc to each field):

{
  "type": "record",
  "name": "User",
  "namespace": "example.avro",
  "fields": [
    { "name": "id", "type": "int" },
    { "name": "name", "type": "string" },
    { "name": "email", "type": "string" },
    { "name": "active", "type": "boolean" }
  ]
}
Step 3

Download or Copy Schema

Once generated, download the schema as an .avsc file or copy it to your clipboard. Use it in:

•
Apache Kafka: Register schema with Kafka Schema Registry for data streaming
•
Hadoop ecosystem: Use with Hive, Pig, Spark for big data processing
•
Data pipelines: Define schemas for ETL processes and data validation

FAQs About Avro Schema Generation

What is an Avro schema?

An Avro schema is a JSON document that lists the fields of a record, their types and optional docs. Kafka, Hadoop, Spark and most Avro readers need it to encode and decode data, and it is what lets a schema change over time without breaking old messages.

How are the field types picked?

From the values themselves, across every record you paste. Whole numbers that fit in 32 bits become int, bigger ones like 8901240544102066246 become long, anything with a decimal point or exponent becomes double, and true/false becomes boolean. Text stays string, so a zip code like "00501" keeps its leading zero. Nested objects turn into their own named records and lists into arrays.

What happens when my records don't all have the same fields?

Paste a list of sample records and the schema is built from all of them. A field that is missing or null in some records becomes optional: ["null", type] with a default of null. If a field holds a number in one record and text in another, you get a union of both types. Before the schema is shown, every record you pasted is checked against it.

Can I register the schema with Kafka Schema Registry?

Yes. The output is a plain record schema, so you can download the .avsc file and register it through the Schema Registry REST API or CLI. Set the record name and namespace above the output first, since the registry and generated classes use them. The schema only describes the samples you gave it, so check the types before you rely on it.

Which Avro types does the generator write?

record, array, int, long, double, string, boolean and null (inside unions for optional fields). JSON has no way to signal float, bytes, map, enum, fixed or logical types like timestamps, so those never come out of the guesswork. A date string stays a string; change it to a logical type by hand if that's what you want.

Why were some of my keys renamed?

Avro names may only use letters, digits and underscores and can't start with a digit, so a key like "first name" becomes first_name and "2fa" becomes _2fa. The original key is kept in the field's doc, and a note above the schema lists every rename.

What other Avro tools are available?

Use JSON to Avro to get a schema together with your data, Avro to JSON to read Avro JSON back, and Avro Schema Validator to check a schema you've edited by hand.