Skip to main content
Glama

Format and validate JSON

format_json
Read-onlyIdempotent

Pretty-print or minify JSON. A number that does not fit in a JavaScript number keeps the digits you sent. Returns the formatted text when it is valid, or the line and column of each syntax error.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "json": "<json>"
    },
    "name": "format_json"
  }
}

Input Schema

NameRequiredDescriptionDefault
jsonYesJSON text to format or validate.
indentNo2
minifyNo
sortKeysNoSort object keys. Array order is kept.

Output Schema

NameRequiredDescriptionDefault
validYes
errorsYes
outputYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / additionalProperties
      Added value: +false
  2. First observed

TDQS

B3.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already cover read-only, idempotent, and closed-world behavior, so the bar is lower. The description adds one genuinely non-obvious trait: numbers that exceed JavaScript number precision keep their original digits, and it states what is returned on success versus failure. It does not mention anything about limits, size caps, or which error it reports first when multiple errors exist.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three short sentences, front-loaded with the tool's action, then a notable edge-case behavior, then the return contract. No filler, and the core capability lands first.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists, so the description need not explain return values in depth, and annotations cover the safety profile. Remaining gaps are untested behaviors such as comments or trailing-comma handling and depth or size limits, which are minor for a formatting utility.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 50%: json and sortKeys carry descriptions, while indent (enum 2/4/tab) and minify are undocumented in both schema and description. The description implies the minify behavior but never explains the indent choices or the key-sorting option, so a baseline 3 is appropriate rather than higher.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb pair and resource: pretty-print or minify JSON, plus the validation behavior visible in the error line/column return. It is clear what the tool does, but it never distinguishes itself from validate JSON schema work done by siblings such as validate_json_schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no when-to-use or when-not-to-use guidance, and no alternative is named. The agent must infer from the statement that this tool also validates JSON, and cannot tell from the description when to prefer it over validate_json_schema.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.