TapCub is live — analytics, insights and live chat, free on one platform

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.

Generator

Generate: one or more samples, separated by new lines (JSON Lines works). Validate: the data to check; several documents are checked one by one.

Schema generated from 3 sample(s).

Samples

3

JSON documents read from the box.

Properties

13

Described in the schema, nested ones included.

Checks

  • OKAll 3 sample(s) pass the generated schema.
JSON Schema (Draft 2020-12)
{
  "$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"
  ]
}
Runs entirely in your browser. Nothing you type here is uploaded or stored by TapCub.

Version v1.0Updated Update history

Read the result

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.

How to use it

From samples to a checked contract

Generate, tighten, then validate.

  1. 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. 2

    Review and tighten

    Copy or download schema.json. Add minimum, pattern, enum and additionalProperties: false where the rules are known.

  3. 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.

Supported keywords

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, $dynamicRef and unevaluatedProperties / unevaluatedItems are not evaluated; you get a warning naming them
  • format is checked when Formats is on (2020-12 treats it as an annotation by default); email and uri use practical patterns, not the full RFC grammars
  • pattern uses JavaScript regular expressions with the u flag, like most browser and Node validators
JSON Schema 2020-12 keywords supported by the validator
Applies toKeywords
Any valuetype, enum, const, allOf, anyOf, oneOf, not, if / then / else, $ref and $defs in the same document, $anchor
Objectsproperties, patternProperties, additionalProperties, required, propertyNames, minProperties, maxProperties, dependentRequired, dependentSchemas
Arraysitems, prefixItems, contains, minContains, maxContains, minItems, maxItems, uniqueItems
Numbersminimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf
StringsminLength, maxLength (in code points), pattern, format: date-time, date, time, email, uri, uuid, ipv4, ipv6, hostname
Worked example

Three purchase events, one schema

What the generator decided for each field of the sample events, and why. The schema describes 13 properties.

Fields of the sample events and the schema generated for them
FieldValues in the samplesGeneratedWhy
time3 timestampsstring, date-time, requiredAll three are RFC 3339 date-times
properties.amount199, 49.5, 120number, requiredOne value has decimals
properties.couponnull, "WELCOME10", missing["string", "null"]Was null once; missing once, so not required
properties.emailOnly in event 3string, emailOptional: absent from two samples
items[].qty1, 2, 3integer, requiredWhole numbers only
properties.currencyUSD, EUR, USDstring (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.

Common mistakes

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.

FAQ

JSON 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.

Changelog

Update history

New features, fixes and data refreshes for this tool, newest first.

  1. · 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

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics