Skip to main content
Glama

JSON to types (TypeScript, Go, Python, Zod)

json_to_types
Read-onlyIdempotent

Generate TypeScript interfaces, Go structs, Python dataclasses, and Zod schemas from a JSON sample, merging array items so missing keys become optional and nulls become nullable.

Instructions

Generate type definitions from a JSON sample: TypeScript interfaces (or type aliases), Go structs with json tags (initialisms like ID/URL, pointers for optional/nullable, optional omitempty), Python dataclasses (snake_case fields with the original key noted) and Zod schemas. All items of an array are merged into one type (missing keys become optional, null makes a field nullable, int+float → number/float64, mixed values → unions); identical shapes share one name. These four are every language the website supports. Give "text" or a file "path". Web version: https://s3eidat.github.io/json-to-types/

Input Schema

NameRequiredDescriptionDefault
pathNoOr: a path to a JSON file (UTF-8; use this for big inputs).
textNoThe JSON sample as inline text.
exportNoTypeScript / Zod: add the export keyword.
outputNoOptional: write the code to this file (with language "all", the four outputs joined by headers).
languageNoOutput language, or "all" for all four.typescript
rootNameNoName of the top-level type (turned into PascalCase).Root
goOmitEmptyNoGo: add ,omitempty to optional fields.
tsTypeAliasNoTypeScript: use "type X = {…}" instead of "interface X {…}".

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.7/5.0
Behavior4/5

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

Annotations already establish readOnlyHint/openWorldHint=false/idempotentHint=true, so the bar is lower, and the description still pays off richly by disclosing the inference algorithm: all array items merged, missing keys become optional, null yields nullability, int+float collapse to number/float64, mixed values become unions, and identical shapes share a name. That is exactly the kind of behavior an agent cannot get from annotations. One tension: annotations say readOnly, yet the `output` parameter writes a file to disk (the description stays silent on this side effect, so the safety profile is not qualified).

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

Conciseness4/5

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

Front-loaded with purpose, then the useful merging rules, with zero fluff. The one sentence that does not earn its place is "These four are every language the website supports," which tells an invoking agent nothing actionable; the trailing URL is defensible as attribution.

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?

With no output schema, the description should convey what comes back; it effectively does by describing each generated artifact, and the merge semantics cover the tricky cases of a sample-driven generator. The gaps are minor: it does not say the code is returned as text (versus only written to `output`), and it leaves the file-write side effect of `output` unexplained relative to the readOnly annotation.

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 description coverage is 100%, so the baseline is 3 and the schema already documents all eight parameters. The description adds meaning for a few of them indirectly — "TypeScript interfaces (or type aliases)" maps to tsTypeAlias, "optional omitempty" maps to goOmitEmpty, and "Give text or a path" restates the input choice — but `export`, `output`, and `rootName` are never touched on, so it does not beat the schema by much.

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?

Opens with a specific verb+resource ("Generate type definitions from a JSON sample") and enumerates the four concrete outputs with their idioms, so the agent knows exactly what it gets back. It does not, however, distinguish itself from the sibling ai_json_schema_infer, which infers a JSON Schema from the same kind of input — the only sibling-differentiating sentence is the meta remark about "every language the website supports," which does not help selection.

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: you supply a JSON sample and pick a language. The one piece of routing guidance is "Give 'text' or a file 'path'", plus a hint that path suits big inputs. There is no explicit when-to-use/when-not, no mention of ai_json_schema_infer as the alternative when the user actually wants a schema rather than code.

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

Deploy Server

Other Tools