Tool directory · Coding agents · Featured in Issue #5

json-schema-for-llms

Last checked

A library, not a command-line tool, that takes JSON too large for an LLM's context window and turns it into a compact JSON Schema with real examples and counts.

json-schema-for-llms overview

What it is

json-schema-for-llms is a library, not a command-line tool, published on npm as json-schema-for-llms. According to the README and the npm package, it takes JSON too large for an LLM's context window and turns it into a compact JSON Schema with real examples and counts. You can then merge schemas and check new documents against them without calling a model. Its maker suggested this tool to Toolsmith Weekly.

Key features

  • The README lists four main functions: describe, which builds a JSON Schema with types, counts, ranges, categories and example records; merge, which combines schemas; fits, which reports field paths a new document adds; and compact, which returns whichever of the document or its schema is smaller, for a prompt.

Getting started

  1. Install it with npm, bun, pnpm or yarn (npm install json-schema-for-llms) and import it as an ES module. It needs Node 18 or later. The README says it also runs on Bun and Deno; on Deno you can add it with deno add jsr:@carmenaresearch/json-schema-for-llms, or use npm:json-schema-for-llms.

Pricing

Free and open source (MIT).

Drafted with AI assistance.


The Toolsmith Take

Built for developers feeding oversized JSON into prompts who want a compact schema with real examples instead of spending context on raw payloads. Merging schemas and checking incoming documents without calling a model is a practical touch. It is a library rather than a CLI, so you have to wire it into your own code. Source

More in Coding Agents