Free tool JSON Schema generator and validator
Paste a few real payloads, such as tracking events or API responses, and get a Draft 2020-12 schema that describes them: types, required keys, nullable fields, nested objects and arrays, date-time and email formats. Then switch to the validator to see exactly which field in a payload breaks the contract.
- Merges several samples
- Errors with JSON Pointer paths
- Runs locally
Generate a schema, then validate against it
The sample is three purchase events as an analytics SDK might send them. Replace them with your own JSON; the schema updates as you type.
Generate: one or more samples, separated by new lines (JSON Lines works). Validate: the data to check; several documents are checked one by one.
A JSON Schema. $ref works within this document (#/$defs/…); remote references are not fetched.
Samples
3
JSON documents read from the box.
Properties
13
Described in the schema, nested ones included.
Errors
—
Validation errors across all documents.
Checks
- OKAll 3 sample(s) pass the generated schema.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"event": {
"type": "string"
},
"time": {
"type": "string",
"format": "date-time"
},
"user_id": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"order_id": {
"type": "string"
},
"amount": {
"type": "number"
},
"currency": {
"type": "string"
},
"coupon": {
"type": [
"string",
"null"
]
},
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"sku": {
"type": "string"
},
"qty": {
"type": "integer"
},
"price": {
"type": "number"
}
},
"required": [
"sku",
"qty",
"price"
]
}
},
"email": {
"type": "string",
"format": "email"
}
},
"required": [
"order_id",
"amount",
"currency",
"items"
]
}
},
"required": [
"event",
"time",
"user_id",
"properties"
]
}Validation errors
Path is a JSON Pointer into your data; schema path points to the rule that failed.
Version v1.0Updated Update history
How the schema is inferred
The generator only knows what is in your samples. Each rule below is how it turns observations into constraints.
Types
Integers only give integer; a mix of integers and decimals gives number. In the sample, amount is 199, 49.5 and 120, so it becomes number, while qty stays integer.
Required
A key is required when it appears in every sample. email is only in the third event, so it is described but not required. One sample makes every key required; add more to relax it.
Nullable
A field that was null at least once gets a type array such as ["string", "null"], the Draft 2020-12 way to say “nullable”.
Formats and enums
format is added only when every value matches it, as with the RFC 3339 timestamps in time. Enums are off by default: three samples are rarely enough to know every allowed value.
Treat the result as a first draft. Add the constraints only you know, such as minimum amounts, ID patterns and allowed currencies, before you use it as a contract.
From samples to a checked contract
Generate, tighten, then validate.
-
1
Paste real samples
Copy a few payloads from your network tab, logs or API client, one per line. Include edge cases: a null coupon, a missing optional field, an empty list.
-
2
Review and tighten
Copy or download
schema.json. Addminimum,pattern,enumandadditionalProperties: falsewhere the rules are known. -
3
Validate payloads
Click Validate with this schema, paste payloads to check, and read each error’s path. The same schema works in Ajv, jsonschema (Python) and other 2020-12 validators.
What the validator checks
The validator is written for this page and covers the keywords most schemas use. It passes the matching cases of the official JSON-Schema-Test-Suite.
- Remote
$ref,$dynamicRefandunevaluatedProperties/unevaluatedItemsare not evaluated; you get a warning naming them formatis checked when Formats is on (2020-12 treats it as an annotation by default); email and uri use practical patterns, not the full RFC grammarspatternuses JavaScript regular expressions with theuflag, like most browser and Node validators
| Applies to | Keywords |
|---|---|
| Any value | type, enum, const, allOf, anyOf, oneOf, not, if / then / else, $ref and $defs in the same document, $anchor |
| Objects | properties, patternProperties, additionalProperties, required, propertyNames, minProperties, maxProperties, dependentRequired, dependentSchemas |
| Arrays | items, prefixItems, contains, minContains, maxContains, minItems, maxItems, uniqueItems |
| Numbers | minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf |
| Strings | minLength, maxLength (in code points), pattern, format: date-time, date, time, email, uri, uuid, ipv4, ipv6, hostname |
Three purchase events, one schema
What the generator decided for each field of the sample events, and why. The schema describes 13 properties.
| Field | Values in the samples | Generated | Why |
|---|---|---|---|
time | 3 timestamps | string, date-time, required | All three are RFC 3339 date-times |
properties.amount | 199, 49.5, 120 | number, required | One value has decimals |
properties.coupon | null, "WELCOME10", missing | ["string", "null"] | Was null once; missing once, so not required |
properties.email | Only in event 3 | string, email | Optional: absent from two samples |
items[].qty | 1, 2, 3 | integer, required | Whole numbers only |
properties.currency | USD, EUR, USD | string (enum ["USD", "EUR"] with enums on) | Repeated values |
The invalid example under the buttons breaks seven rules of a stricter, hand-tightened schema: a time without a time zone, a user ID without the u_ prefix, a missing order ID, a negative amount, a lowercase currency, a fractional quantity and an unexpected source key.
Where generated schemas go wrong
A schema inferred from samples is only as good as the samples.
Too few samples
With one sample, every optional field looks required and every nullable field looks non-null. Feed in the awkward cases too.
Numbers as strings
If one client sends "amount": "199" and another 199, you get a type array. Fix the sender rather than allowing both.
Locking too early
additionalProperties: false rejects every new field. For tracking events that gain properties over time, add it only where the shape is truly fixed.
Mixing drafts
Draft-07 wrote tuples as "items": [ … ] and used definitions. In 2020-12 use prefixItems and $defs, and keep $schema accurate.
Event data with a schema that stays clean
Events sent to TapCub carry their properties as JSON, from the web script, the app and mini-program SDKs, or the server API. Each event is checked on arrival so a wrong type or a missing property does not quietly skew a report.
Data-quality checks
Unexpected event names, missing properties and wrong types are flagged; duplicates can be merged or renamed.
Learn moreCustom events and properties
Track orders, sign-ups or any business action with the fields you care about, then chart and filter by them.
Learn moreSDKs and server API
Seven platform SDKs plus a server API with a Server Key, all sending into one project with shared event names.
Learn moreJSON Schema generator questions
Still have a question?
Chat with the team behind TapCub — we usually reply within a few hours on business days.
How do I generate a JSON Schema from JSON?
Paste one or more JSON documents into the box, one per line. The schema appears as you type: types, nested objects, array items, required keys and formats. Copy it or download schema.json.
Which JSON Schema version does it produce?
Draft 2020-12, declared with "$schema": "https://json-schema.org/draft/2020-12/schema". The output uses only keywords that mean the same in Draft-07 and 2019-09 (type, properties, required, items, format, enum), so most validators accept it.
How does it decide which keys are required?
A key is required if it appears in every sample. That is why several samples matter: with one, every key looks required.
How do I validate JSON against a schema?
Switch Mode to Validate, paste the schema and the JSON. Each error shows the path in your data as a JSON Pointer, such as /properties/items/0/qty, the problem, and the schema rule that failed.
Why does my schema pass in another validator but fail here, or the other way round?
Usually format: in 2020-12 it is an annotation unless the validator is told to assert it. Turn Formats off to match a validator that ignores formats. Also check the warnings for keywords this page does not evaluate, such as remote $ref or unevaluatedProperties.
Can I use the schema to check analytics events?
Yes. A schema per event is a compact tracking contract: it catches a price sent as a string, a missing order ID or a typo in a property name before the data reaches reports.
Is my JSON uploaded?
No. Both generation and validation run in your browser, and the page has no share link, so samples never end up in a URL. Still remove tokens and personal data before pasting payloads into any online tool.
Update history
New features, fixes and data refreshes for this tool, newest first.
-
· v1.0
LaunchedFirst release.
Missing something or found an error? Tell us — requests that come up often go into the next update. All tool updates
Plan the events before you validate them
A tracking plan lists each event and its properties; a schema per event enforces it.