JSON to Avro
Infer an Avro schema from a JSON sample, right in the browser
Input
Output
Paste your JSON on the left and the Avro shows up here.
Or drop a file on this box, , or .
What does JSON to Avro do?
You have one real JSON record, maybe an API response body or a message copied off a Kafka topic, and the producer wants an Apache Avro schema before it will serialize anything. Typing a 30-field .avsc by hand takes ages, and one typo is enough to stop the producer. This page reads the record and writes the schema, with type, name, namespace and fields already in place, so your time goes on the handful of type decisions that need a person.
The inference walks the JSON value and maps types directly: boolean → boolean, whole numbers → long, numbers with a fraction or a decimal point (so 1.0 too) → double, strings → string, objects → nested records, arrays → {type: "array", items: ...}. A field name that Avro accepts is kept as-is; a key like first-name becomes first_name, with the original key noted in the field's doc. Every record name is unique, so a second address object inside billing becomes BillingAddress, and the default namespace is com.example. The mapping follows the type system in the Avro 1.11 specification: primitives, records, arrays, unions. JSON itself is parsed by RFC 8259 rules via the browser's native JSON.parse(), with each number's spelling kept so 1.0 is not read back as 1.
Inference is a starting point, not a finished design. Look at the output, decide whether orderId should be a string or a logical uuid, whether placedAt should be {"type": "long", "logicalType": "timestamp-millis"}, whether nullable fields should be unions like ["null", "string"]. The tool gets you 80% of the way there; the last 20% is where the schema design lives.
How to Use JSON to Avro
The schema is re-inferred as you type, so most of the work is reading: paste a record, check each inferred type, then fix what one sample could not tell the tool.
Paste, Upload, or Load a Sample
Paste a JSON object or array into the left Input panel. For an array, every element is read and merged, so a key that only some records carry becomes an optional field. Click Upload to load a .json file, or hit Sample for a realistic Order array. Quick example of what the input looks like:
{"orderId":"ORD-58231","customerId":"CUST-9012","totalCents":9997,"currency":"USD"} Both single objects and arrays of records work. The output Avro schema gets named Root with namespace com.example: rename to fit your project (the names matter for Schema Registry subjects).
Read the Generated Schema
The right Output panel shows a fully-formed Avro schema. Records nest under fields, arrays declare items, primitives map directly. Look at each field type and decide whether it is what you actually want: the inferrer cannot tell that "2024-04-30" is a date, only that it is a string.
Refine, Copy, or Download
Hit Copy to grab the JSON for a Schema Registry POST. Hit Download to save as schema.avsc for your repo. Adjust types, add logicalType annotations, change nullable fields to ["null", "string"] unions, then validate with the Avro Validator before publishing.
When You'd Actually Use This
Bootstrapping a Kafka Producer
You have a JSON event that an upstream service emits, and you need to publish it to a Kafka topic with Avro encoding. Paste the event, get a draft schema, tweak the types, register it. Beats hand-writing 40 fields.
Migrating a JSON API to Avro
You are turning a REST endpoint into an event-driven service. Drop a real response body in here, get the schema scaffolding, then refine the nullable fields and logical types before producing.
Quick Schema Sketches in Code Review
Someone in a PR asks "what would this look like as Avro?": you paste the JSON sample, take a screenshot of the inferred schema, drop it in the conversation. Faster than firing up a notebook.
Onboarding to a Schema-First Pipeline
New to Avro and trying to understand how a JSON shape maps to records, arrays, and primitives? Run a few JSON samples through this tool and read the output side by side. The mapping clicks fast.
Common Questions
What does it do with nullable fields?
If a key is null in some records and a string in others, or missing from some records, it comes out as the union ["null", "string"] with "default": null, ready for a Schema Registry compatibility check. If it is null in every record, there is nothing to say what it holds, so it gets the bare type "null"; change that to a union with the real type before you publish.
How does it handle arrays of mixed types?
Every element is read. [1, "two", true] gives items the union ["boolean", "long", "string"], and whole numbers next to fractions become double. Records inside an array are merged field by field. An empty array has nothing to read, so its items type is "null": put the real type in before you use it.
Why are integers becoming long instead of int?
JSON numbers do not carry width information, so picking int would silently overflow on values above 2^31. long is the safe default. If you know your data fits in 32 bits, change "long" to "int" in the output before publishing: Avro int reads slightly faster.
Does it generate logical types like timestamp-millis or decimal?
No. The inferrer maps to physical primitives only. To add logical types, edit the output: change "placedAt": "long" to "placedAt": {"type": "long", "logicalType": "timestamp-millis"}. Same for uuid, date, decimal, and the rest.
Is the JSON sent to a server?
No. The record goes through the browser's own JSON.parse() and a short recursive function on this page. The tool has no Share button and makes no request when you type, so the sample stays in your tab.
What's the difference between this and JSON Schema?
JSON Schema is a validation language for JSON documents. Avro is a serialization format with its own schema language used for binary encoding and Schema Registry. Both describe data shape, but Avro gives you compact binary records and schema evolution rules out of the box. If you need binary serialization for Kafka or Hadoop, Avro is the answer.
Other Avro and JSON Tools
An inferred schema still has to be checked, tidied and tried against real records before a registry sees it. Each of those has a page: