{"uid":"cap_y-nPkcpntVna5fol2aM92","slug":"json-schema-inference-from-sample-documents-46394bef","name":"JSON Schema Inference from Sample Documents","description":"Infer a draft-07 JSON Schema from sample JSON document(s). Send one sample as json, or several as samples. Heuristic merge rules: required = keys present in every sample, conflicting types become a type union, integer widens to number, and string formats (date-time, date, email, uri, uuid) are detected from values. Complements json-validate.","url":"https://agent402.tools/api/json-schema-infer","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"json":{"description":"a sample JSON document (object or JSON string)"},"samples":{"type":"array","description":"alternative: 1-50 sample documents merged into one schema"}}},"responseSchema":{"type":"json","example":{"schema":{"type":"object","$schema":"http://json-schema.org/draft-07/schema#","required":["name","age"],"properties":{"age":{"type":"integer"},"name":{"type":"string"}}},"samples":1}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.001","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_oT4hxJe8-GZjEUVZr65NP","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Infers a draft-07 JSON Schema from one or more sample JSON documents using heuristic merge rules","exampleAgentPrompt":"Can you infer a JSON Schema draft-07 from these two sample JSON objects I have? Here are the samples: {\"id\": 1, \"name\": \"Alice\", \"score\": 9.5} and {\"id\": 2, \"name\": \"Bob\", \"active\": true} — I want to know which keys are required and what types everything should be.","exampleUseCases":null,"resultDescription":"A draft-07 JSON Schema object describing the structure of the input sample(s), with required fields set to keys present in every sample, conflicting types expressed as type unions, integers widened to number when mixed with floats, and all discovered property names and their inferred types included.","failureModes":["No json or samples field provided — returns error indicating missing input","samples array exceeds 50 documents — returns validation error","Malformed JSON string passed — returns parse error","Empty samples array — returns error or empty schema","Non-object/non-array JSON at top level may produce unexpected schema shape"],"whenToPreferThis":"Use this endpoint when you have concrete JSON examples and need to quickly derive a formal JSON Schema without writing one by hand. Especially useful when merging multiple JSON samples into a single unified schema that accounts for optional fields and type variations. Prefer this over manual schema authoring when working with API responses, database exports, or user-supplied data of unknown structure.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T01:08:59.341Z","isFirstParty":false}