DevToolBox

JSON Schema Validator

ブラウザ内で処理

JSONデータをJSON Schemaに対してバリデーション。type、required、pattern、min/max等に対応。

複雑な正規表現パターンにはReDoSのリスクがあります。詳しくは正規表現ReDoS対策ガイドを参照してください。 / Complex regular expressions may pose a ReDoS risk.

JSON Schema Validatorの使い方

JSONデータとJSON Schemaを入力すると、スキーマに対する検証結果が自動で表示されます。 type、required、properties、pattern、minimum/maximum、 minLength/maxLength、enum、items、additionalPropertiesに対応しています。 APIレスポンスの型検証やデータ品質チェックに活用できます。

図1: JSONデータとJSON Schemaを突き合わせて検証し、JSONPathでエラー箇所を報告する仕組み
JSONデータとJSON Schemaの検証の仕組みJSONデータのageプロパティが文字列20、スキーマ側でageはinteger型を要求している場合、検証結果として$.ageの位置にtype must be integerというエラーが報告されることを示す図。下部には対応する9個のキーワード(type, required, properties, pattern, minimum/maximum, minLength/maxLength, enum, items, additionalProperties)を一覧表示するJSONデータJSON Schemaname: "Alice"age: "20"required: [name, age]properties.age:{ type: integer }検証$.agemust beinteger対応キーワードtyperequiredpropertiespatternminimum/maximumminLength/maxLengthenumitemsadditionalProperties

How to Use the JSON Schema Validator

This tool validates JSON data against a JSON Schema definition. It supports type checking, required properties, string patterns, numeric ranges, array constraints, enum values, and additional properties validation. Enter your JSON data and schema to get detailed error reports with JSONPath locations automatically. Perfect for API contract testing and data validation during development.

required・null・型指定の検証対策 / Fixing required, null, type, format and $ref validation issues

エラー / Error原因 / Cause対処 / Fix
required なのに null が通る/通らない
required vs nullable confusion
required は「キーの存在」のみ検証。null 値の許可は type の問題
required checks key presence, not null values
null を許すなら type: ["string", "null"] と配列で指定
Use a type array to allow null
未知のキーがすり抜ける
Unknown keys pass validation
additionalProperties はデフォルト true(何でも許可)
additionalProperties defaults to true
厳密に検証するなら additionalProperties: false を明示
Set additionalProperties: false explicitly
整数のつもりが小数が通る
Floats pass as integers
type: number は小数を含む。整数限定は integer
number allows floats; use integer
ID やカウントには type: "integer" を使う
Use integer for IDs and counts
日付文字列が検証されない
Date strings not validated
format: date-time はバリデータによっては注釈扱い(検証しない)
format is annotation-only in many validators
厳密にするなら pattern で正規表現指定、またはバリデータの format 検証を有効化
Use pattern or enable format assertion
$ref が解決できない
$ref not resolving
外部参照やアンカーはバリデータの設定・読み込みが必要
External refs need registration with the validator
本ツールは単一スキーマ向け。$ref 多用時は Ajv 等で検証
Use Ajv for multi-document schemas

Ajv・jsonschemaで違反パスを取得 / Reporting validation paths with Ajv and jsonschema

JavaScript (Ajv)

import Ajv from "ajv";
const ajv = new Ajv({ allErrors: true });
const validate = ajv.compile(schema);
if (!validate(data)) console.log(validate.errors);  // instancePath付き

Python (jsonschema)

from jsonschema import validate, ValidationError
try:
    validate(instance=data, schema=schema)
except ValidationError as e:
    print(e.json_path, e.message)

ageのminimum・required違反例 / Age validation failures for minimum and required

Schema: { "type": "object",
  "required": ["name", "age"],
  "properties": {
    "name": { "type": "string" },
    "age":  { "type": "integer", "minimum": 0 } } }

データ: { "name": "Taro", "age": -1 }
→ NG: $.age — minimum 違反 (-1 < 0)

データ: { "name": "Taro" }
→ NG: $ — required 違反 ("age" がない)

APIのJSONとスキーマを端末内で検証 / Keeping API JSON and schemas local during validation

The JSON you validate is typically a real API response or a production data sample — exactly the data you should not paste into unknown servers. This validator runs the entire check in your browser: schema and data never leave your device, and the tool works offline. Confirm via the DevTools Network tab — zero requests during validation.

検証対象は本物のAPIレスポンスや本番データのサンプルであることがほとんど。 本ツールは検証がブラウザ内で完結し、データ・スキーマとも外部送信されません。 スキーマ設計の基礎はJSON Schemaで型を保証する基本で解説しています。

🔒 すべての処理はブラウザ内で完結し、入力データはサーバーへ送信されません。登録不要・無料。 / All processing runs in your browser; nothing is uploaded. Free, no sign-up. プライバシーポリシー / Privacy Policy

参考資料 / References

関連ガイド / Related Guides