Home/Tools/@tpmjs/tools-jq

format

@tpmjs/tools-jq

Pretty-print JSON with consistent formatting.

Official
utilities
v0.1.0
MIT

Interactive Playground

Test @tpmjs/tools-jq (format) with AI-powered execution

0/2000 characters

Installation & Usage

Install this tool and use it with the AI SDK

1. Install the package

npm install @tpmjs/tools-jq
pnpm add @tpmjs/tools-jq
yarn add @tpmjs/tools-jq
bun add @tpmjs/tools-jq
deno add npm:@tpmjs/tools-jq

2. Import the tool

import { format } from '@tpmjs/tools-jq';

3. Use with AI SDK

import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { format } from '@tpmjs/tools-jq';

const result = await generateText({
  model: openai('gpt-4o'),
  tools: { format },
  prompt: 'Your prompt here...',
});

console.log(result.text);

Signature

(json: string, compact?: boolean, sortKeys?: boolean) => Promise<unknown>

Tags

agent
consistent
filter
format
formatting
jq
json
pretty
print
query
tpmjs
utilities

Parameters

Available configuration options

Auto-extracted
json
Required
Type: string

JSON string to format.

sortKeys
Optional
Type: boolean

Sort object keys alphabetically. Default false.

compact
Optional
Type: boolean

Compact output (no whitespace). Default false.

Schema extracted: 3/1/2026, 4:28:55 AM

README

@tpmjs/tools-jq

jq JSON processing tools for AI agents. Query, filter, and format JSON data using jq expressions.

Requirements

The jq binary must be available in the system PATH. The TPMJS executor Docker image includes it.

Tools

  • query — Run a jq expression on JSON input
  • format — Pretty-print JSON

Usage

import { query, format } from '@tpmjs/tools-jq';

Statistics

Downloads/month

91

GitHub Stars

15

Quality Score

87%

Bundle Size

NPM Keywords

tpmjs
jq
json
query
filter
agent

Maintainers

thomasdavis(thomasalwyndavis@gmail.com)

Frameworks

vercel-ai