jqschema

Infers compact JSON structural schemas with keys and types using jq.

5.1k|530|Updated Aug 12, 2025
One-click install
npx skills add https://github.com/github/gh-aw --skill jqschema
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: jqschema
Source: https://github.com/github/gh-aw/tree/main/.github/skills/jqschema
Command: npx skills add https://github.com/github/gh-aw --skill jqschema

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires jq.

What problem does it solve?

Exploring unknown JSON APIs or large payloads is slow when you must inspect full data just to learn its shape. This Skill condenses any JSON input into a compact structural schema showing keys and value types, so you can understand the data before writing queries.

Core Features & Use Cases

  • Schema Discovery: Replaces object values with type names (string, number, boolean, null) and reduces arrays to their first element's structure.
  • Pipe-Friendly: Accepts JSON from files or any command output via stdin, such as gh api or curl responses.
  • Use Case: When exploring the GitHub search API for the first time, pipe gh api search/repositories?q=language:go through the script with perPage=1 to instantly see the response structure instead of reading thousands of lines of raw JSON.

Quick Start

Pipe any JSON output through ./.github/skills/jqschema/jqschema.sh to see its compact structural schema.

Frequently Asked Questions about jqschema

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I discover the structure of a JSON API response?

Pipe the API response through the jqschema.sh script, for example: gh api search/repositories?q=language:go | ./jqschema.sh. It outputs a compact schema where each value is replaced by its type name, so you see keys and types without the full data.

How to infer JSON schema using jq from the command line?

Use the provided jqschema.sh script, which runs a jq program that recursively walks the JSON, replacing object values with type names like string or number and reducing arrays to their first element's structure. Feed it JSON via stdin from a file or command.

Does jqschema handle nested objects and arrays?

Yes, the script recursively walks nested objects and arrays. Arrays are reduced to the structure of their first element, and empty arrays are returned as empty arrays, so deeply nested JSON still produces a compact schema.

What are the limitations of type-based JSON schema inference?

The output shows only structural types, not full JSON Schema with constraints, formats, or required fields. Arrays are represented by their first element only, so heterogeneous arrays may be misrepresented. Use it for quick exploration, not formal validation.

What dependencies does jqschema require to run?

The script requires bash and the jq command-line JSON processor. No other packages are needed; it runs as a single self-contained shell script that reads JSON from stdin.