📐

JSON to JSON Schema

Generate a JSON Schema (Draft-07) from sample JSON with properties, required fields and array items. Supports JSON Schema generator. Runs locally — no data uploaded. Free at oltool.net.

Generated
JSON
JSON Schema
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer"
    },
    "name": {
      "type": "string"
    },
    "active": {
      "type": "boolean"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "profile": {
      "type": "object",
      "properties": {
        "age": {
          "type": "integer"
        },
        "city": {
          "type": "string"
        }
      },
      "required": [
        "age",
        "city"
      ]
    }
  },
  "required": [
    "id",
    "name",
    "active",
    "tags",
    "profile"
  ]
}

About JSON to JSON Schema

JSON Schema is the de-facto standard for describing and validating JSON structures, but writing one by hand is tedious and error-prone. This tool parses your sample JSON locally in the browser and infers a Draft-07 schema: each field's type, object properties and required lists, and array item types. All inference is local with nothing uploaded. Tip: Bookmark this tool for quick access whenever you need format conversion. All processing happens locally in your browser — no data upload, so feel free to paste sensitive content.

Use Cases

  • Validate API contracts — Generate a schema for request/response payloads to validate data at runtime and reject malformed input.
  • Validate forms and config — Turn a config sample into a schema and validate user input or config files with libraries like ajv.
  • Bootstrap OpenAPI — Get a schema quickly as the basis for components in OpenAPI/Swagger docs.
  • Data quality gates — Use the schema as an entry check in data pipelines so downstream consumers get stable structures.
  • Align team structures — Use the schema as a shared contract between frontend and backend to cut communication overhead.
  • Generate UI forms — Derive a JSON Schema from a data sample to drive auto-generated form components with validation rules.
  • Define database validation — Create a schema from a sample document to enforce shape constraints on JSON columns in PostgreSQL or MongoDB.

FAQ

Which schema version is produced?

It outputs JSON Schema Draft-07 by default, compatible with mainstream validators like ajv. Adjust to another draft after copying if needed.

Are all fields marked required?

Controlled by the "Mark required" toggle. When on, every field present in the sample is listed as required; for optional fields, turn it off and adjust manually.

How are mixed array types handled?

When array elements differ, the tool lists each possible sub-schema under anyOf to match the real data.

Are integers and floats distinguished?

Yes. Whole numbers infer to integer and decimals to number for more precise validation.

Can it validate my JSON?

This tool generates the schema. You can then validate real data with libraries like ajv or jsonschema, or an online validator.

Any browser compatibility requirements?

This tool works in all modern browsers (Chrome, Firefox, Edge, Safari). No plugins or extensions required.

Can I use it offline?

After initial load, most features work offline. The core logic runs entirely in your browser with no network dependency.