Skip to main content

GraphQL Schema Formatter

Validate and reformat GraphQL SDL (Schema Definition Language) — type, interface, enum, input, scalar, union and directive definitions. Reports the exact syntax error and line/column on invalid schemas, and reprints valid ones with consistent 2- or 4-space indentation, optionally sorting types and fields alphabetically.

Input

Drop a file or browse
One file · text
Or

Formatting Options

Output

Formatted Schema
 
Was this helpful?

Guides

Paste a GraphQL schema — type, interface, enum, input, scalar, union, or directive definitions written in SDL (Schema Definition Language) — and get back a validated, consistently formatted version. The GraphQL Schema Formatter parses your schema with the same reference parser GraphQL itself uses, so a real syntax error is reported with its exact line and column instead of a guess, and a valid schema is reprinted with clean, uniform spacing.

It's built for the moments a schema arrives messy: pasted from a pull request, copied out of documentation, generated by a code-first framework, or handed over by an AI assistant with inconsistent indentation. Drop it in, get a canonical version back.

How to use it

  1. Paste your GraphQL SDL into the input box, or upload a .graphql, .gql, or .sdl file.
  2. Optionally set the Indent Width (2 or 4 spaces) and toggle Sort Types & Fields Alphabetically.
  3. Copy the formatted result, or download it as schema.graphql.

Formatting runs automatically as you type or change an option.

What it does

  • Real validation. Your schema is parsed with graphql-js, the reference implementation of the GraphQL specification — the same parser underlying tools like Apollo Server and GraphQL Code Generator. A malformed schema (a missing colon, an unclosed brace, an unknown token) returns the parser's exact error message plus the line and column where it broke, instead of silently producing garbage.
  • Consistent indentation. Choose 2 or 4 spaces; every block — type, interface, input, enum, schema, and multi-line descriptions — reindents uniformly.
  • Descriptions are preserved. Both single-line ("...") and block ("""...""") description strings stay attached to the type or field they document.
  • Optional alphabetical sorting. When enabled, top-level definitions are grouped by kind (scalars, enums, interfaces, unions, object types, inputs, directives — a schema { ... } block always stays first) and sorted by name within each group; fields inside type/interface/input bodies and values inside enum bodies are sorted alphabetically too. Union member order is left untouched, since it can be meaningful (a preferred type listed first).

Privacy

Everything happens client-side in your browser. Your schema is never uploaded to a server.

Does it preserve # comments?

No. GraphQL's own lexer treats #-style comments as insignificant and drops them before parsing — they're not part of the schema's AST, so no formatter built on the reference parser can round-trip them. Description strings ("..." and """..."""), which genuinely are part of the schema, are preserved exactly.

Does it validate references between types?

It checks syntax — that the SDL parses as valid GraphQL — not full schema semantics (an unresolved type reference, a directive used somewhere it isn't declared for). Build the schema with a GraphQL server library for that level of validation.

Can I format an entire federated or multi-file schema?

Paste them as one combined document — extend type/extend interface/extend schema definitions are supported and formatted like any other definition.

What does "Sort Alphabetically" actually reorder?

Two independent things: the order of top-level definitions (grouped by kind, then by name) and the order of fields/enum values within each definition. It never renames anything or changes a type/argument.

graphqlsdlschemaformattervalidatorapibeautify

Use it from code

From 3 credits per call

REST API

curl -X POST https://api.iotools.cloud/v1/tool/graphql-schema-formatter \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "graphqlInput": "\"\"\"\nA simple blog API schema.\n\"\"\"\nschema {\n  que…",
    "indentWidth": "2",
    "sortAlphabetically": ""
  }'

Swap in your own key from your account. The tool's fields are the body — no wrapper.

Ask an AI agent

Use the IOTools `graphql-schema-formatter` tool (GraphQL Schema Formatter) on this input:

YOUR_INPUT_HERE

Paste this at any agent connected to the IOTools MCP server, then add your input.

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.