DevTools Logo

NoSQL Validator

NoSQL Validator

Validate a JSON document against a JSON Schema or MongoDB $jsonSchema

Document (JSON)

Schema (JSON Schema / $jsonSchema)

Examples

Validate a user document

Input
{ "name": "Ada", "age": 36 } against a schema requiring name (string) and age (int, min 0)
Output
VALID — both required fields are present and correctly typed.

Load the sample to see a document and a MongoDB $jsonSchema validator checked field by field.

Catch a wrong type

Input
{ "age": "thirty-six" } against { age: { bsonType: "int" } }
Output
age — Expected type int, got string.

The validator points at the exact field path so you can fix the document or the schema.

About this tool

Document stores such as MongoDB can enforce a shape at write time with a validator built from JSON Schema, or MongoDB's $jsonSchema. Authoring that schema by hand is error-prone, and a single wrong keyword silently lets bad data in.

Paste a document and a schema and the validator checks every node: the expected type (including BSON aliases like int and bool), required properties, additionalProperties:false, array items, enum membership, string minLength/maxLength and pattern, and numeric minimum/maximum. Each failure points at the exact field path. It supports a practical subset of draft-07 plus MongoDB bsonType and the $jsonSchema wrapper.

How to use this tool

  1. Paste the document

    Enter the JSON document you want to validate on the left.

  2. Paste the schema

    Enter a JSON Schema, optionally wrapped in { "$jsonSchema": { ... } }, on the right.

  3. Read the result

    A VALID badge means it matches; otherwise each error names the offending field path and why.

  4. Iterate

    Fix the document or correct the schema and the result updates live.

Common mistakes

Mistake:Forgetting required.

Fix:Listing a property in properties does not make it required — add its name to the required array.

Mistake:Using 'number' when MongoDB wants 'int'.

Fix:Use bsonType (e.g. 'int', 'long', 'double') for MongoDB validators; this tool understands both.

Frequently asked questions

Which JSON Schema version is supported?

A practical subset of draft-07: type/bsonType, properties, required, additionalProperties, items, enum, pattern, min/maxLength, min/maxItems, and minimum/maximum.

Can I paste a MongoDB $jsonSchema validator?

Yes. Wrap it as { "$jsonSchema": { ... } } exactly as you would for db.runCommand({ collMod }), or paste the schema object directly.

Is my document or schema uploaded?

No. Validation runs entirely in your browser.

References & standards