home / skills / aidotnet / moyucode / json-validator

json-validator skill

/skills/tools/json-validator

This skill validates JSON files against JSON Schema, reports detailed errors, and offers auto-fix suggestions to streamline data integrity.

npx playbooks add skill aidotnet/moyucode --skill json-validator

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
930 B
---
name: json-validator
description: 根据JSON Schema验证JSON文件,提供详细错误报告和自动修复建议。
metadata:
  short-description: 验证JSON/Schema
source:
  repository: https://github.com/python-jsonschema/jsonschema
  license: MIT
---

# JSON Validator Tool

## Description
Validate JSON files against JSON Schema with detailed error reporting and formatting.

## Trigger
- `/json-validate` command
- User needs to validate JSON
- User wants schema validation

## Usage

```bash
# Validate JSON syntax
python scripts/json_validator.py data.json

# Validate against schema
python scripts/json_validator.py data.json --schema schema.json

# Format JSON
python scripts/json_validator.py data.json --format --output formatted.json

# Minify JSON
python scripts/json_validator.py data.json --minify
```

## Tags
`json`, `validate`, `schema`, `format`, `lint`

## Compatibility
- Codex: ✅
- Claude Code: ✅

Overview

This skill validates JSON files against JSON Schema, offering precise error reporting and actionable fix suggestions. It also supports formatting and minifying JSON to enforce consistent style. Use it to catch schema mismatches, type errors, missing required fields, and structural problems before runtime.

How this skill works

The validator parses your JSON and runs it through a JSON Schema validator to identify violations, type mismatches, missing properties, and pattern/enum failures. It produces line-and-column-aware error messages, suggests specific fixes (for example: add missing property, change type, correct enum value), and can optionally auto-format or minify the JSON. You can validate against a provided schema file or run a syntax-only check when no schema is supplied.

When to use it

  • Before committing JSON configuration or data files to catch schema errors early.
  • During CI checks to enforce JSON shape and types across a codebase.
  • When integrating third-party JSON APIs to validate received payloads.
  • To clean up and standardize JSON formatting across files.
  • When debugging runtime errors caused by invalid JSON structure or types.

Best practices

  • Always supply the canonical JSON Schema for the environment you target to get precise validation.
  • Run validation as part of pre-commit or CI pipelines to prevent regressions.
  • Use the formatter option to maintain consistent formatting and minimize diff noise.
  • Review suggested fixes before applying automated changes to avoid unintended data loss.
  • Combine schema validation with unit tests for complex data transformations.

Example use cases

  • Validate config.json against config-schema.json before deploying a service.
  • Lint and format a set of JSON fixtures to keep repository style consistent.
  • Validate API responses against a contract schema during integration tests.
  • Minify large JSON payloads for production upload or transmission.
  • Generate a concise error report for a malformed JSON file to share with teammates.

FAQ

Can the tool auto-fix all validation errors?

It provides automated suggestions and can apply simple fixes (formatting, adding missing optional fields) but complex semantic fixes require manual review.

What happens if no schema is provided?

The tool performs syntax validation and formatting/minifying but cannot check structural rules without a schema.

Does it report exact locations of errors?

Yes. Errors include line and column references and a human-friendly message with a recommended correction.