YAML to JSON Schema Converter

Convert YAML configuration to JSON Schema for validation and documentation

JSON Schema will appear here...

What is YAML to JSON Schema Converter?

JSON Schema is a vocabulary that allows you to annotate and validate JSON documents, and it is widely used for form validation, API contract testing, and configuration management. This tool converts YAML configuration files into JSON Schema definitions by analyzing the structure and inferring types from the values. Strings become "string", integers become "integer", floats become "number", booleans become "boolean", null becomes "null", arrays become "array" with inferred item types, and objects become "object" with nested properties. All keys present in the YAML are marked as required by default, producing a conservative schema that you can relax by removing optional fields from the required array. The output is compatible with JSON Schema Draft-07.

How to Use

  1. Paste your YAML configuration into the left panel — any valid YAML with nested objects, arrays, and primitive values works
  2. Click "Convert" to analyze the structure and generate a JSON Schema definition
  3. Review the output: each property has an inferred type, and all keys are listed in the required array
  4. Copy the schema and use it with validators like AJV, jsonschema, or online validators to validate other YAML or JSON data
  5. Customize the schema by adding validation keywords (minLength, pattern, enum, minimum, maximum) as needed for your use case

Why Use This Tool?

Automatically infers types from YAML values: string, number, integer, boolean, null, array, and object
Generates a required fields list from all present keys, producing a strict schema by default
Handles nested objects and arrays recursively, producing accurate property definitions at every depth level
Produces valid JSON Schema Draft-07 compatible output that works with all major validators
Enables IDE autocomplete, form generation, and documentation from your existing YAML configuration

Tips & Best Practices

  • The schema represents the structure of your YAML, not its constraints — add validation keywords like minLength, pattern, or enum manually
  • Review the required array and remove fields that are optional in your actual use case
  • For arrays, the schema infers items from the first element only — adjust if your array contains mixed types
  • Use the generated schema with AJV, jsonschema, or online validators to enforce configuration standards across your team

Frequently Asked Questions

Why convert YAML to JSON Schema?

JSON Schema is a standard format for describing and validating JSON/YAML data structures. By converting your YAML to JSON Schema, you can validate other YAML files against this schema, generate documentation automatically, enable IDE autocomplete and suggestions, and use configuration management tools that require JSON Schema format.

How does type inference work?

The converter examines each value in your YAML and maps it to a JSON Schema type: strings become "string", integers become "integer", floats become "number", booleans become "boolean", null becomes "null", arrays become "array" with inferred items, and objects become "object" with nested properties.

When should I NOT use this converter?

If your YAML uses advanced features like anchors, aliases, or custom type tags, the inference may be incorrect. Also, if you need a schema with complex validation rules (oneOf, anyOf, $ref to shared definitions), this tool provides a structural starting point but you will need to add those constraints manually.

Are all fields marked as required?

Yes, by default all fields present in the YAML are marked as required in the schema. This is a conservative approach. You should review the schema and remove fields from the "required" array if they are optional in your actual use case.

Is my data sent to a server?

No. All processing happens entirely in your browser. Your YAML content never leaves your device, making this safe for configuration files containing sensitive values.

Real-world Examples

Application config to JSON Schema for validation

Converting a YAML application configuration to JSON Schema so that other config files can be validated against the same structure.

Input
server:
  host: localhost
  port: 8080
database:
  url: postgres://localhost:5432/mydb
  pool_size: 10
logging:
  level: info
  format: json
Output
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "server": {
      "type": "object",
      "properties": {
        "host": { "type": "string" },
        "port": { "type": "integer" }
      },
      "required": ["host", "port"]
    },
    "database": {
      "type": "object",
      "properties": {
        "url": { "type": "string" },
        "pool_size": { "type": "integer" }
      },
      "required": ["url", "pool_size"]
    },
    "logging": {
      "type": "object",
      "properties": {
        "level": { "type": "string" },
        "format": { "type": "string" }
      },
      "required": ["level", "format"]
    }
  },
  "required": ["server", "database", "logging"]
}

Feature flags config with array inference

Converting a feature flags YAML configuration to JSON Schema, where arrays of strings are inferred as array types with string items.

Input
features:
  enabled:
    - dark_mode
    - notifications
    - analytics
  disabled:
    - beta_ui
Output
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "features": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "array",
          "items": { "type": "string" }
        },
        "disabled": {
          "type": "array",
          "items": { "type": "string" }
        }
      },
      "required": ["enabled", "disabled"]
    }
  },
  "required": ["features"]
}

Related Tools