Avro Schema Generator - Generate Apache Avro Schemas from JSON Online
Free online tool to generate Apache Avro schemas from JSON data with automatic type inference for Kafka and Hadoop.
Loading Avro Schema Generator...
Generate Avro Schemas from JSON - Complete Guide
Input Your JSON Data
Get your JSON data ready for schema generation. You have several convenient options:
.json fileJSON input example:
{ "id": 1, "name": "Elara Quinn", "email": "[email protected]", "active": true }
Automatic Schema Generation
Watch as your JSON is transformed into a valid Apache Avro schema. The generator provides:
avsc and every input record is validated against itGenerated 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" } ] }
Download or Copy Schema
Once generated, download the schema as an .avsc file or copy it to your clipboard. Use it in:
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.
Related Tools
JSON to Avro
Convert JSON data to Apache Avro format with automatic schema generation
Avro to JSON
Convert Apache Avro data to JSON format with schema validation
Avro Fixer
Fix and repair broken Avro schemas with automatic syntax error correction
Avro Schema Validator
Validate Apache Avro schemas with syntax and structure checking for Kafka
Avro Formatter
Format and beautify Apache Avro schemas with proper indentation
CSV to Avro
Convert CSV files to Apache Avro format with automatic schema generation