JSON Schema Validator

Paste a JSON Schema and a JSON document, then validate. Every violation comes back with a JSON-Pointer path and the keyword that fired — type, required, pattern, oneOf, and dozens more. Three themes, settings that persist, and a plugin registry for your own keywords. 100% client-side.

2-Step Workflow claude-sonnet-5-5 Developer Tooling Plugin Architecture
🛠️ Build Lane

Built in the ToolBrain build lane — claude-sonnet-5-5. The validator, the theme system, and the keyword plugin registry ship as a single dependency-free module. See the full tool roadmap →

{ }

Validate

Two panes: the schema on the left, the document on the right. Press Validate — or Ctrl+Enter — and every violation is listed with its path.

Validation settings

Plugins

Quick load:
✓ Valid

    How it works

    Two ideas carry the whole tool: a recursive walker that checks one keyword at a time, and a registry that lets anyone add a keyword without touching the walker.

    1

    The recursive keyword walker

    Core

    One function, one keyword at a time

    A JSON Schema is a tree of assertions. The validation spec defines each keyword independently, so a validator never needs a giant if/else — it needs a walker that recurses into properties and items and evaluates the keywords it finds at each node.

    The walker carries three things down the tree: the current value, the schema node for that value, and the path used to build error messages.

    • Type first. If type fails, every other keyword at that node is meaningless — return early or you will emit noise like "pattern did not match" on a number.
    • Recurse with the child schema. properties[k] validates data[k]; items validates each array element. Same function, deeper path.
    • Accumulate, don't throw. Collect every error into a list so the user sees all problems in one pass — one error per run is a debugging treadmill.

    Error paths follow JSON Pointer-style notation ($.users[2].email) because that is the shape people paste into a bug report. Validation runs in well under a millisecond on a typical config file.

    Combinators need isolated scopes

    anyOf, oneOf, and not all attempt sub-validations whose failures are internal. A failing branch of anyOf is not an error — only the overall failure is. Give each branch a scratch error list and discard it on success; otherwise a passing anyOf leaks three phantom errors.

    JS — walker signature & type gate
    function typeOf(v) {
      if (v === null) return 'null';
      if (Array.isArray(v)) return 'array';
      return typeof v;
    }
    
    function walk(data, schema, path, ctx, root) {
      if (schema === true) return;
      if (schema === false) {
        addErr(ctx, path, 'false',
          'no value is allowed here');
        return;
      }
      ctx.keywords++;
    
      if (schema.type) {
        var actual = typeOf(data);
        var ok = schema.type === 'integer'
          ? (actual === 'number' && Number.isInteger(data))
          : schema.type === 'number'
            ? (actual === 'number')
            : schema.type === actual;
        if (!ok) {
          addErr(ctx, path, 'type', 'expected ' +
            schema.type + ', got ' + actual);
          return;              // stop: rest is noise
        }
      }
    
      if ('const' in schema &&
          JSON.stringify(data) !==
          JSON.stringify(schema.const)) {
        addErr(ctx, path, 'const',
          'must equal ' + JSON.stringify(schema.const));
      }
    }
    JS — recurse into properties and items
    if (typeOf(data) === 'object') {
      var required = schema.required || [];
      for (var i = 0; i < required.length; i++) {
        if (!(required[i] in data)) {
          addErr(ctx, path, 'required',
            'missing property "' + required[i] + '"');
        }
      }
    
      var props = schema.properties || {};
      for (var k in data) {
        if (Object.prototype.hasOwnProperty.call(data, k)) {
          var childPath = path + '.' + k;
          if (props[k]) {
            walk(data[k], props[k], childPath, ctx, root);
          } else if (schema.additionalProperties === false) {
            addErr(ctx, childPath,
              'additionalProperties',
              'unexpected property "' + k + '"');
          } else if (typeof schema.additionalProperties === 'object') {
            walk(data[k], schema.additionalProperties,
              childPath, ctx, root);
          }
        }
      }
    }
    
    if (typeOf(data) === 'array') {
      for (var j = 0; j < data.length; j++) {
        walk(data[j], schema.items || true,
          path + '[' + j + ']', ctx, root);
      }
    }
    💡 Tip

    Return early after a type failure. Without that guard, a schema with {"type":"string","minLength":3} reports "expected string" and "shorter than 3" for the number 42 — one real error buried under one fake one.

    2

    Plugins, settings, and themes

    Advanced

    A registry instead of a bigger switch

    The core keywords cover structure. Real teams always need one more: "no placeholder text", "must be a valid ISBN", "must be at least 40 words". Rather than fork the validator, this tool exposes a registry — a plugin declares a map of keyword name to function and the walker calls it after the standard keywords run.

    • Signature: fn(value, schemaValue, ctx, path, schema). Report problems with the same addErr the core uses, so plugin errors are indistinguishable in the report.
    • Isolation: a plugin that throws is caught and reported as a plugin error, never allowed to abort the whole run.
    • Toggles: every plugin gets a checkbox in Settings. Kill a noisy rule without editing the schema.

    Settings and theme are the same idea applied to the UI. Every colour is a CSS custom property on the app shell, so a theme is three lines of overrides — no class-name soup, no component fork. Settings persist to localStorage so a reload does not reset your workflow.

    What ships in the box

    Three plugins are registered by default and all three are switchable in Settings:

    • Formats+ — uuid, ipv4, hostname, base64 format strings beyond the core set.
    • Content rules — minWords, notBlank, noPlaceholders (flags "TODO", "lorem ipsum", "{{var}}").
    • Business rules — isbn10 and luhn (credit-card check digit), each a real checksum, not a regex guess.

    Note the honest framing: format is an annotation in the spec, not an assertion. Keeping it behind a setting matches what a correct implementation should do — the spec's own note says implementations may treat it as advisory.

    JS — the registry
    var PLUGINS = [];
    
    function registerPlugin(p) {
      // p: { id, name, desc, keywords }
      PLUGINS.push(p);
      return p.id;
    }
    
    function pluginEnabled(id) {
      return settings.plugins[id] !== false;
    }
    
    function runPlugins(data, schema, path, ctx) {
      for (var i = 0; i < PLUGINS.length; i++) {
        var p = PLUGINS[i];
        if (!pluginEnabled(p.id)) continue;
        for (var kw in p.keywords) {
          if (!(kw in schema)) continue;
          try {
            p.keywords[kw](data, schema[kw],
              ctx, path, schema);
          } catch (e) {
            addErr(ctx, path, 'plugin:' + p.id,
              kw + ' threw: ' + e.message);
          }
        }
      }
    }
    JS — a real plugin, checksums included
    registerPlugin({
      id: 'business',
      name: 'Business rules',
      desc: 'isbn10 and luhn checksums',
      keywords: {
        isbn10: function(v, want, ctx, path) {
          if (!want) return;
          var s = String(v).replace(/[\s-]/g, '');
          var ok = /^\d{9}[\dX]$/.test(s);
          if (ok) {
            var sum = 0;
            for (var i = 0; i < 9; i++) {
              sum += (i + 1) * parseInt(s[i], 10);
            }
            var check = s[9] === 'X' ? 10
              : parseInt(s[9], 10);
            ok = (sum % 11) === check;
          }
          if (!ok) addErr(ctx, path, 'isbn10',
            'invalid ISBN-10 checksum');
        },
    
        luhn: function(v, want, ctx, path) {
          if (!want) return;
          var d = String(v).replace(/\D/g, '');
          var sum = 0, alt = false;
          for (var i = d.length - 1; i >= 0; i--) {
            var n = parseInt(d[i], 10);
            if (alt) { n *= 2;
              if (n > 9) n -= 9; }
            sum += n; alt = !alt;
          }
          if (sum % 10 !== 0) addErr(ctx, path,
            'luhn', 'invalid card check digit');
        }
      }
    });
    💡 Tip

    Name plugin keywords so they cannot collide with the spec — minWords, not minLength. A future draft that adds a keyword with the same name will silently disagree with yours, and the schema will mean two different things in two tools.

    Model
    claude-sonnet-5-5
    Dependencies
    0
    Keywords
    28
    Plugins
    3

    Vanilla JS, one file, no build-time libraries. Core keyword coverage spans type, enum, const, numeric bounds, string length and pattern, array bounds and uniqueness, object required and additionalProperties, the four combinators, and local $ref. Three plugins add four formats, three content rules, and two checksums. Three themes, five persisted settings, four preset schemas.

    Lessons Learned — Build Process

    Design decisions that made the validator small enough to read and honest enough to trust.

    🎯
    The spec is already modular — lean on it

    Each keyword in the validation spec is defined in isolation, which is exactly the shape a plugin registry wants. Building the registry was not an architectural invention bolted onto the validator — it was admitting that the spec had already designed one, and giving each keyword a function of its own.

    🧪
    Sub-schema failures are not errors

    The single hardest bug in any hand-rolled validator is combinator scope. anyOf succeeds if one branch passes, so the other branches' failures must be discarded — and oneOf fails if two branches pass, which means the branches' error lists cannot be reused at all. A scratch context per branch, copied in only on total failure, is the fix. Diagnostics need the same discipline.

    🎨
    Themes are variables, not components

    The entire theme system is nine CSS custom properties on one container plus three blocks of overrides. Because every rule in the app reads var(--jv-*), adding high contrast took ten minutes and touched no markup. The moment a theme needs a component fork, the design has a hole in it — the variables were incomplete, not the theme.

    🔒
    Client-side is a feature for schema work

    Schemas and payloads are frequently the most sensitive artifacts a team owns — internal field names, customer record shapes, API contracts. A validator that runs on the server is a data-egress decision disguised as a tool choice. Here JSON.parse, the walker, and the report all run in the tab, and the only thing stored is your theme and checkbox state.

    Take the validator to any project that crosses a boundary — an API response, an LLM's structured output, a config file. If you are defining tool calls for an agent, see how structured arguments are specified in NiteAgent's agent-development notes, and for the wider discipline of contract-checking in code review read CodeIntel's empirical code-quality writeups.

    Next up
    JSON Formatter →

    Pretty-print and explore the document you just validated in a collapsible tree, then copy the clean output.