Skip to main content
Glama

Format or minify JSON

format_json
Read-only

Validate JSON and return it pretty-printed or minified, optionally with object keys sorted A-Z (recursively; array order is kept). Returns the formatted JSON as text. Invalid JSON returns an error naming the problem and its position. Input up to 100 KB.

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
jsonYesThe JSON text to validate and format
indentNo2 or 4 spaces, a tab, or minify to remove all whitespace2
sortKeysNoSort object keys alphabetically at every level

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changed
    • addedInput schema / properties / indent / description
      Added value: +"2 or 4 spaces, a tab, or minify to remove all whitespace"
    • changedInput schema / properties / json / description
      Previous value: -"The JSON text"New value: +"The JSON text to validate and format"
    • addedInput schema / properties / sortKeys / description
      Added value: +"Sort object keys alphabetically at every level"
  2. First observed

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already cover the safety profile (readOnlyHint true, destructiveHint false, openWorldHint false), and the description adds real context on top: array order is preserved during sorting, invalid input returns an error naming the problem and its position, and input is capped at 100 KB. The return shape ('formatted JSON as text') is also disclosed, which matters because there is no output schema.

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?

Four compact sentences, front-loaded with the core action and output form, then behavior on sorting, error handling, and the size limit. Every sentence carries distinct information with no redundancy.

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

Completeness5/5

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

With no output schema, the description supplies the missing return-value information (formatted JSON text, or an error with problem description and position). Combined with the size limit and the sorting caveat, an agent has everything needed to call this correctly without trial and error.

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

Parameters4/5

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

Schema description coverage is 100%, so the baseline is 3, but the description earns more by clarifying that key sorting is recursive and that array order is untouched — a genuine semantic point beyond the schema's 'at every level' wording. It also confirms the input is treated as text to be validated, reinforcing the required 'json' parameter's role.

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

Purpose5/5

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

The description opens with a specific verb and resource ('Validate JSON and return it pretty-printed or minified') plus the optional sorting behavior, so the agent knows exactly what the tool produces. None of the sibling utilities (base64, hash_text, convert_units) overlap with JSON formatting/validation, and this is evident from the stated scope.

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

Usage Guidelines3/5

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

Usage is implied rather than stated: the agent can infer it should call this when it needs to validate or reformat JSON text, and the sorting option is described in context. There is no explicit when-to-use/when-not-to-use framing or mention of alternatives, though for a self-contained utility with unrelated siblings the practical risk is low.

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.