DevToolBox

JSON Schema Validator

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

JSON Schema Validatorの使い方

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

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, click validate, and get detailed error reports with JSONPath locations. Perfect for API contract testing and data validation during development.

よくあるエラーと対処 / Common Errors and Fixes

エラー / 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

コード例 / Code Examples

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)

検証例 / Before & After

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" がない)

Why browser-only?

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で型を保証する基本で解説しています。

開発をもっと効率的に

PR