Avro Schema Generator: Turn JSON Samples into Typed Avro Record Schemas
Learn how the free Avro Schema Generator from Online Tools Forge turns JSON samples into Apache Avro record schemas with inferred types, logical types like uuid and timestamp-millis, and nullable unions β entirely in your browser.
Table of Contents
Avro Schema Generator: Turn JSON Samples into Typed Avro Record Schemas
Kafka and data pipelines speak Avro. Apache Avro is the default serialization format for event streaming, the contract format behind schema registries, and a common table format for analytical storage, thanks to its compact binary encoding and well-defined evolution rules.
But every event needs a schema, and writing Avro record schemas by hand for every payload is tedious. You must list every field, pick the right primitive type, wrap nullable fields in unions, and keep defaults consistent with union ordering. One mistyped int where a long belongs can fail a compatibility check or corrupt a day of events.
That is exactly what our Avro Schema Generator solves: paste a JSON sample and get a complete Avro record schema with inferred types, logical types like uuid and timestamp-millis, nullable unions, and nested records β instantly, entirely client-side in your browser. This guide explains how inference works and where the output fits real pipelines.
Why Use Avro Schema Generator?
- Eliminate hand-written boilerplate. A realistic Avro record runs to dozens of lines of nested fields, type, and default declarations. Generating the skeleton from real data takes seconds.
- Get nullable fields right the first time. Avro expresses nullability as a union, and the default must match the first branch. The generator emits ["null", "type"] with null first and a matching default β the ordering compatibility rules expect.
- Preserve meaning with logical types. A string that is really a UUID, or a timestamp that should serialize as milliseconds, carries far more information annotated with uuid or timestamp-millis β patterns the generator detects automatically.
- Model nested payloads faithfully. The generator turns nested JSON objects into nested record types that mirror your data, so consumers see the same hierarchy producers send.
- Bootstrap schema-first workflows quickly. Standing up a Kafka topic, registering a subject, or defining a lake table all go faster from an accurate draft.
- Keep sensitive payloads private. Generation runs entirely in your browser, so production samples and internal event shapes never leave your machine.
Key Features
| Feature | What it does |
|---|---|
| JSON-to-Avro record generation | Paste a JSON object and get a complete, well-formed Avro record schema |
| Primitive type inference | Maps JSON values to string, int, long, double, and boolean based on the sample |
| Nullable unions | Fields that can be null become ["null", "type"] unions with a matching default |
| Logical types | Detects UUID-shaped strings and ISO timestamps, annotating uuid and timestamp-millis |
| Nested records | Nested JSON objects become nested Avro record types with their own field lists |
| 100% client-side processing | Everything runs in your browser β no uploads, no accounts, no waiting |
Three details deserve emphasis:
- Integer width matters. The generator distinguishes int (32-bit) from long (64-bit) by magnitude, so large identifiers and epoch millis land on the correct type.
- Unions follow Avro conventions. Every generated union starts with null, keeping the auto-generated default: null valid under Avro's first-branch rule.
- The output is a starting point. Edit the result freely β add enums, rename fields, tighten constraints β before it reaches a registry.
How to Use
- Paste your JSON sample. Drop a representative payload β a single object is enough β into the input panel; real-traffic samples beat idealized ones.
- Review the generated record. The tool instantly produces a record with a fields array, one entry per JSON key, each carrying an inferred type.
- Check unions and logical types. Confirm nullable fields really are optional in your domain, and that detected uuid and timestamp-millis annotations match your intent.
- Rename the record if needed. Give it a meaningful name matching your topic or entity so registry subjects stay readable.
- Copy and integrate. Paste the schema into your producer configuration, register it in your schema registry, or commit it beside your table definitions.
Avro Types from JSON Samples
The heart of the tool is inference: mapping every value in your JSON to the most accurate Avro type. Here is a sample next to the schema it produces:
{
"userId": "7c9e6679-7422-4def-b2c9-3b71c8a2e5d1",
"email": "[email protected]",
"signedUpAt": "2026-09-13T08:30:00Z",
"score": null,
"active": true
}
{
"type": "record",
"name": "GeneratedRecord",
"fields": [
{
"name": "userId",
"type": { "type": "string", "logicalType": "uuid" }
},
{
"name": "email",
"type": "string"
},
{
"name": "signedUpAt",
"type": { "type": "long", "logicalType": "timestamp-millis" }
},
{
"name": "score",
"type": ["null", "double"],
"default": null
},
{
"name": "active",
"type": "boolean"
}
]
}
Primitive inference starts from the value itself. Quoted text becomes string, whole numbers become int or long by magnitude, decimals become double, and true/false become boolean.
Nullable unions encode optionality. Because score was null in the sample, it widens to ["null", "double"]. The null branch comes first β not cosmetically: Avro requires a default to match the first union branch, so default: null is only valid under this ordering.
Logical types add semantics on top of storage. A uuid annotation tells consumers the string must be a valid UUID. timestamp-millis goes further: the underlying type is a long, but the logical type declares it holds milliseconds since the epoch, letting a JSON timestamp round-trip into a compact eight-byte number without losing meaning.
Nested objects become nested records. An address object produces an address field typed as its own record, with inner fields inferred the same way, so hierarchies survive intact.
Defaults deserve a caveat. The generator writes a default only for nullable unions, where null is provably safe as the first branch. Everywhere else, absence is deliberate β a wrong default silently fills values producers never intended to send.
Practical Use Cases
Kafka Producer Setup
Stand up a new topic with a proper schema from day one. Capture a realistic payload, generate the record, and wire it into your producer configuration, so the schema starts from the payload itself instead of drifting from the serializing code.
Schema Registry Bootstrapping
Registering the first version of a subject is where typos hurt most, because every later version is checked against it. Generate the initial schema from a known-good payload, review it, and register it so future changes evolve through compatibility checks against a trusted foundation.
Data Lake Table Definitions
Analytical engines that ingest Avro need schemas to define columns and types. Generate a schema from a sample event and hand it to your ingestion job, and your userId column arrives as a UUID-aware string rather than an anonymous varchar.
Teaching and Learning Avro
Union and logical-type rules are easiest to learn by example. Paste JSON, tweak a value from 42 to null, and see exactly how the schema responds.
Best Practices
- Review inferred types against intent. Inference sees one sample. If quantity should never be fractional, or a long should really be int, adjust before the schema becomes a contract.
- Feed it representative data. A field that happens to be null in your sample becomes nullable in the schema β use samples that cover real-world variation.
- Add defaults before evolving. Give existing fields sensible defaults before adding new ones, so old consumers can read new records during rolling deployments.
- Register through compatibility checks. Evolve schemas through your registry's compatibility mode β it turns a schema from documentation into a guarantee.
- Be deliberate about precision. double suits scores and ratios, but for money you will usually want bytes with a decimal logical type.
- Version schemas like code. Commit generated schemas and review changes through pull requests, giving schema evolution the same scrutiny as application code.
Start Generating Avro Schemas Today
Stop hand-writing fields arrays and second-guessing union ordering. Open the Avro Schema Generator, paste a JSON sample, and get a clean, convention-following Avro record schema in seconds β entirely in your browser.
Related Tools You Might Like:
- JSON Formatter β pretty-print, minify, and validate your JSON sample before turning it into a schema.
- JSON Schema Visualizer β explore nested JSON structures visually to understand the shape you are modeling.
- OpenAPI to TypeScript Converter β turn API contracts into TypeScript types for type-safe producers and consumers.
Happy schema forging, and may your unions always be null-first.
Frequently Asked Questions
Q: Is my JSON uploaded to a server?
A: No. The Avro Schema Generator runs entirely in your browser using client-side JavaScript. Your samples never leave your machine, making it safe for production payloads and internal event shapes.
Q: Why is null always the first branch in generated unions?
A: Avro requires a field's default value to match the first branch of its union. By emitting ["null", "type"] with default: null, the generator produces schemas that are valid as-is and clear compatibility checks that would reject the reversed ordering.
Q: When does inference choose int instead of long?
A: Whole numbers that fit in the 32-bit integer range become int; larger values become long. If your values are small today but will grow, switch to long before registering the schema.
Q: Can I use the generated schema with Kafka directly?
A: Yes. The output is a standard .avsc record schema, ready to paste into producer configuration, a schema registry subject, or any Avro-compatible ingestion job.